1 // Licensed to the Apache Software Foundation (ASF) under one 2 // or more contributor license agreements. See the NOTICE file 3 // distributed with this work for additional information 4 // regarding copyright ownership. The ASF licenses this file 5 // to you under the Apache License, Version 2.0 (the 6 // "License"); you may not use this file except in compliance 7 // with the License. You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, 12 // software distributed under the License is distributed on an 13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 // KIND, either express or implied. See the License for the 15 // specific language governing permissions and limitations 16 // under the License. 17 18 // Eager evaluation convenience APIs for invoking common functions, including 19 // necessary memory allocations 20 21 #pragma once 22 23 #include <string> 24 #include <utility> 25 26 #include "arrow/compute/function.h" 27 #include "arrow/compute/type_fwd.h" 28 #include "arrow/datum.h" 29 #include "arrow/result.h" 30 #include "arrow/util/macros.h" 31 #include "arrow/util/visibility.h" 32 33 namespace arrow { 34 namespace compute { 35 36 /// \addtogroup compute-concrete-options 37 /// 38 /// @{ 39 40 class ARROW_EXPORT ArithmeticOptions : public FunctionOptions { 41 public: 42 explicit ArithmeticOptions(bool check_overflow = false); 43 constexpr static char const kTypeName[] = "ArithmeticOptions"; 44 bool check_overflow; 45 }; 46 47 class ARROW_EXPORT ElementWiseAggregateOptions : public FunctionOptions { 48 public: 49 explicit ElementWiseAggregateOptions(bool skip_nulls = true); 50 constexpr static char const kTypeName[] = "ElementWiseAggregateOptions"; Defaults()51 static ElementWiseAggregateOptions Defaults() { return ElementWiseAggregateOptions{}; } 52 bool skip_nulls; 53 }; 54 55 /// Rounding and tie-breaking modes for round compute functions. 56 /// Additional details and examples are provided in compute.rst. 57 enum class RoundMode : int8_t { 58 /// Round to nearest integer less than or equal in magnitude (aka "floor") 59 DOWN, 60 /// Round to nearest integer greater than or equal in magnitude (aka "ceil") 61 UP, 62 /// Get the integral part without fractional digits (aka "trunc") 63 TOWARDS_ZERO, 64 /// Round negative values with DOWN rule and positive values with UP rule 65 TOWARDS_INFINITY, 66 /// Round ties with DOWN rule 67 HALF_DOWN, 68 /// Round ties with UP rule 69 HALF_UP, 70 /// Round ties with TOWARDS_ZERO rule 71 HALF_TOWARDS_ZERO, 72 /// Round ties with TOWARDS_INFINITY rule 73 HALF_TOWARDS_INFINITY, 74 /// Round ties to nearest even integer 75 HALF_TO_EVEN, 76 /// Round ties to nearest odd integer 77 HALF_TO_ODD, 78 }; 79 80 class ARROW_EXPORT RoundOptions : public FunctionOptions { 81 public: 82 explicit RoundOptions(int64_t ndigits = 0, 83 RoundMode round_mode = RoundMode::HALF_TO_EVEN); 84 constexpr static char const kTypeName[] = "RoundOptions"; Defaults()85 static RoundOptions Defaults() { return RoundOptions(); } 86 /// Rounding precision (number of digits to round to) 87 int64_t ndigits; 88 /// Rounding and tie-breaking mode 89 RoundMode round_mode; 90 }; 91 92 class ARROW_EXPORT RoundToMultipleOptions : public FunctionOptions { 93 public: 94 explicit RoundToMultipleOptions(double multiple = 1.0, 95 RoundMode round_mode = RoundMode::HALF_TO_EVEN); 96 explicit RoundToMultipleOptions(std::shared_ptr<Scalar> multiple, 97 RoundMode round_mode = RoundMode::HALF_TO_EVEN); 98 constexpr static char const kTypeName[] = "RoundToMultipleOptions"; Defaults()99 static RoundToMultipleOptions Defaults() { return RoundToMultipleOptions(); } 100 /// Rounding scale (multiple to round to). 101 /// 102 /// Should be a scalar of a type compatible with the argument to be rounded. 103 /// For example, rounding a decimal value means a decimal multiple is 104 /// required. Rounding a floating point or integer value means a floating 105 /// point scalar is required. 106 std::shared_ptr<Scalar> multiple; 107 /// Rounding and tie-breaking mode 108 RoundMode round_mode; 109 }; 110 111 /// Options for var_args_join. 112 class ARROW_EXPORT JoinOptions : public FunctionOptions { 113 public: 114 /// How to handle null values. (A null separator always results in a null output.) 115 enum NullHandlingBehavior { 116 /// A null in any input results in a null in the output. 117 EMIT_NULL, 118 /// Nulls in inputs are skipped. 119 SKIP, 120 /// Nulls in inputs are replaced with the replacement string. 121 REPLACE, 122 }; 123 explicit JoinOptions(NullHandlingBehavior null_handling = EMIT_NULL, 124 std::string null_replacement = ""); 125 constexpr static char const kTypeName[] = "JoinOptions"; Defaults()126 static JoinOptions Defaults() { return JoinOptions(); } 127 NullHandlingBehavior null_handling; 128 std::string null_replacement; 129 }; 130 131 class ARROW_EXPORT MatchSubstringOptions : public FunctionOptions { 132 public: 133 explicit MatchSubstringOptions(std::string pattern, bool ignore_case = false); 134 MatchSubstringOptions(); 135 constexpr static char const kTypeName[] = "MatchSubstringOptions"; 136 137 /// The exact substring (or regex, depending on kernel) to look for inside input values. 138 std::string pattern; 139 /// Whether to perform a case-insensitive match. 140 bool ignore_case; 141 }; 142 143 class ARROW_EXPORT SplitOptions : public FunctionOptions { 144 public: 145 explicit SplitOptions(int64_t max_splits = -1, bool reverse = false); 146 constexpr static char const kTypeName[] = "SplitOptions"; 147 148 /// Maximum number of splits allowed, or unlimited when -1 149 int64_t max_splits; 150 /// Start splitting from the end of the string (only relevant when max_splits != -1) 151 bool reverse; 152 }; 153 154 class ARROW_EXPORT SplitPatternOptions : public FunctionOptions { 155 public: 156 explicit SplitPatternOptions(std::string pattern, int64_t max_splits = -1, 157 bool reverse = false); 158 SplitPatternOptions(); 159 constexpr static char const kTypeName[] = "SplitPatternOptions"; 160 161 /// The exact substring to split on. 162 std::string pattern; 163 /// Maximum number of splits allowed, or unlimited when -1 164 int64_t max_splits; 165 /// Start splitting from the end of the string (only relevant when max_splits != -1) 166 bool reverse; 167 }; 168 169 class ARROW_EXPORT ReplaceSliceOptions : public FunctionOptions { 170 public: 171 explicit ReplaceSliceOptions(int64_t start, int64_t stop, std::string replacement); 172 ReplaceSliceOptions(); 173 constexpr static char const kTypeName[] = "ReplaceSliceOptions"; 174 175 /// Index to start slicing at 176 int64_t start; 177 /// Index to stop slicing at 178 int64_t stop; 179 /// String to replace the slice with 180 std::string replacement; 181 }; 182 183 class ARROW_EXPORT ReplaceSubstringOptions : public FunctionOptions { 184 public: 185 explicit ReplaceSubstringOptions(std::string pattern, std::string replacement, 186 int64_t max_replacements = -1); 187 ReplaceSubstringOptions(); 188 constexpr static char const kTypeName[] = "ReplaceSubstringOptions"; 189 190 /// Pattern to match, literal, or regular expression depending on which kernel is used 191 std::string pattern; 192 /// String to replace the pattern with 193 std::string replacement; 194 /// Max number of substrings to replace (-1 means unbounded) 195 int64_t max_replacements; 196 }; 197 198 class ARROW_EXPORT ExtractRegexOptions : public FunctionOptions { 199 public: 200 explicit ExtractRegexOptions(std::string pattern); 201 ExtractRegexOptions(); 202 constexpr static char const kTypeName[] = "ExtractRegexOptions"; 203 204 /// Regular expression with named capture fields 205 std::string pattern; 206 }; 207 208 /// Options for IsIn and IndexIn functions 209 class ARROW_EXPORT SetLookupOptions : public FunctionOptions { 210 public: 211 explicit SetLookupOptions(Datum value_set, bool skip_nulls = false); 212 SetLookupOptions(); 213 constexpr static char const kTypeName[] = "SetLookupOptions"; 214 215 /// The set of values to look up input values into. 216 Datum value_set; 217 /// Whether nulls in `value_set` count for lookup. 218 /// 219 /// If true, any null in `value_set` is ignored and nulls in the input 220 /// produce null (IndexIn) or false (IsIn) values in the output. 221 /// If false, any null in `value_set` is successfully matched in 222 /// the input. 223 bool skip_nulls; 224 }; 225 226 class ARROW_EXPORT StrptimeOptions : public FunctionOptions { 227 public: 228 explicit StrptimeOptions(std::string format, TimeUnit::type unit); 229 StrptimeOptions(); 230 constexpr static char const kTypeName[] = "StrptimeOptions"; 231 232 std::string format; 233 TimeUnit::type unit; 234 }; 235 236 class ARROW_EXPORT StrftimeOptions : public FunctionOptions { 237 public: 238 explicit StrftimeOptions(std::string format, std::string locale = "C"); 239 StrftimeOptions(); 240 241 constexpr static char const kTypeName[] = "StrftimeOptions"; 242 243 constexpr static const char* kDefaultFormat = "%Y-%m-%dT%H:%M:%S"; 244 245 /// The desired format string. 246 std::string format; 247 /// The desired output locale string. 248 std::string locale; 249 }; 250 251 class ARROW_EXPORT PadOptions : public FunctionOptions { 252 public: 253 explicit PadOptions(int64_t width, std::string padding = " "); 254 PadOptions(); 255 constexpr static char const kTypeName[] = "PadOptions"; 256 257 /// The desired string length. 258 int64_t width; 259 /// What to pad the string with. Should be one codepoint (Unicode)/byte (ASCII). 260 std::string padding; 261 }; 262 263 class ARROW_EXPORT TrimOptions : public FunctionOptions { 264 public: 265 explicit TrimOptions(std::string characters); 266 TrimOptions(); 267 constexpr static char const kTypeName[] = "TrimOptions"; 268 269 /// The individual characters that can be trimmed from the string. 270 std::string characters; 271 }; 272 273 class ARROW_EXPORT SliceOptions : public FunctionOptions { 274 public: 275 explicit SliceOptions(int64_t start, int64_t stop = std::numeric_limits<int64_t>::max(), 276 int64_t step = 1); 277 SliceOptions(); 278 constexpr static char const kTypeName[] = "SliceOptions"; 279 int64_t start, stop, step; 280 }; 281 282 class ARROW_EXPORT NullOptions : public FunctionOptions { 283 public: 284 explicit NullOptions(bool nan_is_null = false); 285 constexpr static char const kTypeName[] = "NullOptions"; Defaults()286 static NullOptions Defaults() { return NullOptions{}; } 287 288 bool nan_is_null; 289 }; 290 291 enum CompareOperator : int8_t { 292 EQUAL, 293 NOT_EQUAL, 294 GREATER, 295 GREATER_EQUAL, 296 LESS, 297 LESS_EQUAL, 298 }; 299 300 struct ARROW_EXPORT CompareOptions { CompareOptionsCompareOptions301 explicit CompareOptions(CompareOperator op) : op(op) {} CompareOptionsCompareOptions302 CompareOptions() : CompareOptions(CompareOperator::EQUAL) {} 303 enum CompareOperator op; 304 }; 305 306 class ARROW_EXPORT MakeStructOptions : public FunctionOptions { 307 public: 308 MakeStructOptions(std::vector<std::string> n, std::vector<bool> r, 309 std::vector<std::shared_ptr<const KeyValueMetadata>> m); 310 explicit MakeStructOptions(std::vector<std::string> n); 311 MakeStructOptions(); 312 constexpr static char const kTypeName[] = "MakeStructOptions"; 313 314 /// Names for wrapped columns 315 std::vector<std::string> field_names; 316 317 /// Nullability bits for wrapped columns 318 std::vector<bool> field_nullability; 319 320 /// Metadata attached to wrapped columns 321 std::vector<std::shared_ptr<const KeyValueMetadata>> field_metadata; 322 }; 323 324 struct ARROW_EXPORT DayOfWeekOptions : public FunctionOptions { 325 public: 326 explicit DayOfWeekOptions(bool count_from_zero = true, uint32_t week_start = 1); 327 constexpr static char const kTypeName[] = "DayOfWeekOptions"; DefaultsDayOfWeekOptions328 static DayOfWeekOptions Defaults() { return DayOfWeekOptions(); } 329 330 /// Number days from 0 if true and from 1 if false 331 bool count_from_zero; 332 /// What day does the week start with (Monday=1, Sunday=7). 333 /// The numbering is unaffected by the count_from_zero parameter. 334 uint32_t week_start; 335 }; 336 337 /// Used to control timestamp timezone conversion and handling ambiguous/nonexistent 338 /// times. 339 struct ARROW_EXPORT AssumeTimezoneOptions : public FunctionOptions { 340 public: 341 /// \brief How to interpret ambiguous local times that can be interpreted as 342 /// multiple instants (normally two) due to DST shifts. 343 /// 344 /// AMBIGUOUS_EARLIEST emits the earliest instant amongst possible interpretations. 345 /// AMBIGUOUS_LATEST emits the latest instant amongst possible interpretations. 346 enum Ambiguous { AMBIGUOUS_RAISE, AMBIGUOUS_EARLIEST, AMBIGUOUS_LATEST }; 347 348 /// \brief How to handle local times that do not exist due to DST shifts. 349 /// 350 /// NONEXISTENT_EARLIEST emits the instant "just before" the DST shift instant 351 /// in the given timestamp precision (for example, for a nanoseconds precision 352 /// timestamp, this is one nanosecond before the DST shift instant). 353 /// NONEXISTENT_LATEST emits the DST shift instant. 354 enum Nonexistent { NONEXISTENT_RAISE, NONEXISTENT_EARLIEST, NONEXISTENT_LATEST }; 355 356 explicit AssumeTimezoneOptions(std::string timezone, 357 Ambiguous ambiguous = AMBIGUOUS_RAISE, 358 Nonexistent nonexistent = NONEXISTENT_RAISE); 359 AssumeTimezoneOptions(); 360 constexpr static char const kTypeName[] = "AssumeTimezoneOptions"; 361 362 /// Timezone to convert timestamps from 363 std::string timezone; 364 365 /// How to interpret ambiguous local times (due to DST shifts) 366 Ambiguous ambiguous; 367 /// How to interpret non-existent local times (due to DST shifts) 368 Nonexistent nonexistent; 369 }; 370 371 struct ARROW_EXPORT WeekOptions : public FunctionOptions { 372 public: 373 explicit WeekOptions(bool week_starts_monday = true, bool count_from_zero = false, 374 bool first_week_is_fully_in_year = false); 375 constexpr static char const kTypeName[] = "WeekOptions"; DefaultsWeekOptions376 static WeekOptions Defaults() { return WeekOptions{}; } ISODefaultsWeekOptions377 static WeekOptions ISODefaults() { 378 return WeekOptions{/*week_starts_monday*/ true, 379 /*count_from_zero=*/false, 380 /*first_week_is_fully_in_year=*/false}; 381 } USDefaultsWeekOptions382 static WeekOptions USDefaults() { 383 return WeekOptions{/*week_starts_monday*/ false, 384 /*count_from_zero=*/false, 385 /*first_week_is_fully_in_year=*/false}; 386 } 387 388 /// What day does the week start with (Monday=true, Sunday=false) 389 bool week_starts_monday; 390 /// Dates from current year that fall into last ISO week of the previous year return 391 /// 0 if true and 52 or 53 if false. 392 bool count_from_zero; 393 /// Must the first week be fully in January (true), or is a week that begins on 394 /// December 29, 30, or 31 considered to be the first week of the new year (false)? 395 bool first_week_is_fully_in_year; 396 }; 397 398 /// @} 399 400 /// \brief Get the absolute value of a value. 401 /// 402 /// If argument is null the result will be null. 403 /// 404 /// \param[in] arg the value transformed 405 /// \param[in] options arithmetic options (overflow handling), optional 406 /// \param[in] ctx the function execution context, optional 407 /// \return the elementwise absolute value 408 ARROW_EXPORT 409 Result<Datum> AbsoluteValue(const Datum& arg, 410 ArithmeticOptions options = ArithmeticOptions(), 411 ExecContext* ctx = NULLPTR); 412 413 /// \brief Add two values together. Array values must be the same length. If 414 /// either addend is null the result will be null. 415 /// 416 /// \param[in] left the first addend 417 /// \param[in] right the second addend 418 /// \param[in] options arithmetic options (overflow handling), optional 419 /// \param[in] ctx the function execution context, optional 420 /// \return the elementwise sum 421 ARROW_EXPORT 422 Result<Datum> Add(const Datum& left, const Datum& right, 423 ArithmeticOptions options = ArithmeticOptions(), 424 ExecContext* ctx = NULLPTR); 425 426 /// \brief Subtract two values. Array values must be the same length. If the 427 /// minuend or subtrahend is null the result will be null. 428 /// 429 /// \param[in] left the value subtracted from (minuend) 430 /// \param[in] right the value by which the minuend is reduced (subtrahend) 431 /// \param[in] options arithmetic options (overflow handling), optional 432 /// \param[in] ctx the function execution context, optional 433 /// \return the elementwise difference 434 ARROW_EXPORT 435 Result<Datum> Subtract(const Datum& left, const Datum& right, 436 ArithmeticOptions options = ArithmeticOptions(), 437 ExecContext* ctx = NULLPTR); 438 439 /// \brief Multiply two values. Array values must be the same length. If either 440 /// factor is null the result will be null. 441 /// 442 /// \param[in] left the first factor 443 /// \param[in] right the second factor 444 /// \param[in] options arithmetic options (overflow handling), optional 445 /// \param[in] ctx the function execution context, optional 446 /// \return the elementwise product 447 ARROW_EXPORT 448 Result<Datum> Multiply(const Datum& left, const Datum& right, 449 ArithmeticOptions options = ArithmeticOptions(), 450 ExecContext* ctx = NULLPTR); 451 452 /// \brief Divide two values. Array values must be the same length. If either 453 /// argument is null the result will be null. For integer types, if there is 454 /// a zero divisor, an error will be raised. 455 /// 456 /// \param[in] left the dividend 457 /// \param[in] right the divisor 458 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 459 /// \param[in] ctx the function execution context, optional 460 /// \return the elementwise quotient 461 ARROW_EXPORT 462 Result<Datum> Divide(const Datum& left, const Datum& right, 463 ArithmeticOptions options = ArithmeticOptions(), 464 ExecContext* ctx = NULLPTR); 465 466 /// \brief Negate values. 467 /// 468 /// If argument is null the result will be null. 469 /// 470 /// \param[in] arg the value negated 471 /// \param[in] options arithmetic options (overflow handling), optional 472 /// \param[in] ctx the function execution context, optional 473 /// \return the elementwise negation 474 ARROW_EXPORT 475 Result<Datum> Negate(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 476 ExecContext* ctx = NULLPTR); 477 478 /// \brief Raise the values of base array to the power of the exponent array values. 479 /// Array values must be the same length. If either base or exponent is null the result 480 /// will be null. 481 /// 482 /// \param[in] left the base 483 /// \param[in] right the exponent 484 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 485 /// \param[in] ctx the function execution context, optional 486 /// \return the elementwise base value raised to the power of exponent 487 ARROW_EXPORT 488 Result<Datum> Power(const Datum& left, const Datum& right, 489 ArithmeticOptions options = ArithmeticOptions(), 490 ExecContext* ctx = NULLPTR); 491 492 /// \brief Left shift the left array by the right array. Array values must be the 493 /// same length. If either operand is null, the result will be null. 494 /// 495 /// \param[in] left the value to shift 496 /// \param[in] right the value to shift by 497 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 498 /// \param[in] ctx the function execution context, optional 499 /// \return the elementwise left value shifted left by the right value 500 ARROW_EXPORT 501 Result<Datum> ShiftLeft(const Datum& left, const Datum& right, 502 ArithmeticOptions options = ArithmeticOptions(), 503 ExecContext* ctx = NULLPTR); 504 505 /// \brief Right shift the left array by the right array. Array values must be the 506 /// same length. If either operand is null, the result will be null. Performs a 507 /// logical shift for unsigned values, and an arithmetic shift for signed values. 508 /// 509 /// \param[in] left the value to shift 510 /// \param[in] right the value to shift by 511 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 512 /// \param[in] ctx the function execution context, optional 513 /// \return the elementwise left value shifted right by the right value 514 ARROW_EXPORT 515 Result<Datum> ShiftRight(const Datum& left, const Datum& right, 516 ArithmeticOptions options = ArithmeticOptions(), 517 ExecContext* ctx = NULLPTR); 518 519 /// \brief Compute the sine of the array values. 520 /// \param[in] arg The values to compute the sine for. 521 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 522 /// \param[in] ctx the function execution context, optional 523 /// \return the elementwise sine of the values 524 ARROW_EXPORT 525 Result<Datum> Sin(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 526 ExecContext* ctx = NULLPTR); 527 528 /// \brief Compute the cosine of the array values. 529 /// \param[in] arg The values to compute the cosine for. 530 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 531 /// \param[in] ctx the function execution context, optional 532 /// \return the elementwise cosine of the values 533 ARROW_EXPORT 534 Result<Datum> Cos(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 535 ExecContext* ctx = NULLPTR); 536 537 /// \brief Compute the inverse sine (arcsine) of the array values. 538 /// \param[in] arg The values to compute the inverse sine for. 539 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 540 /// \param[in] ctx the function execution context, optional 541 /// \return the elementwise inverse sine of the values 542 ARROW_EXPORT 543 Result<Datum> Asin(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 544 ExecContext* ctx = NULLPTR); 545 546 /// \brief Compute the inverse cosine (arccosine) of the array values. 547 /// \param[in] arg The values to compute the inverse cosine for. 548 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 549 /// \param[in] ctx the function execution context, optional 550 /// \return the elementwise inverse cosine of the values 551 ARROW_EXPORT 552 Result<Datum> Acos(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 553 ExecContext* ctx = NULLPTR); 554 555 /// \brief Compute the tangent of the array values. 556 /// \param[in] arg The values to compute the tangent for. 557 /// \param[in] options arithmetic options (enable/disable overflow checking), optional 558 /// \param[in] ctx the function execution context, optional 559 /// \return the elementwise tangent of the values 560 ARROW_EXPORT 561 Result<Datum> Tan(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 562 ExecContext* ctx = NULLPTR); 563 564 /// \brief Compute the inverse tangent (arctangent) of the array values. 565 /// \param[in] arg The values to compute the inverse tangent for. 566 /// \param[in] ctx the function execution context, optional 567 /// \return the elementwise inverse tangent of the values 568 ARROW_EXPORT 569 Result<Datum> Atan(const Datum& arg, ExecContext* ctx = NULLPTR); 570 571 /// \brief Compute the inverse tangent (arctangent) of y/x, using the 572 /// argument signs to determine the correct quadrant. 573 /// \param[in] y The y-values to compute the inverse tangent for. 574 /// \param[in] x The x-values to compute the inverse tangent for. 575 /// \param[in] ctx the function execution context, optional 576 /// \return the elementwise inverse tangent of the values 577 ARROW_EXPORT 578 Result<Datum> Atan2(const Datum& y, const Datum& x, ExecContext* ctx = NULLPTR); 579 580 /// \brief Get the natural log of a value. 581 /// 582 /// If argument is null the result will be null. 583 /// 584 /// \param[in] arg The values to compute the logarithm for. 585 /// \param[in] options arithmetic options (overflow handling), optional 586 /// \param[in] ctx the function execution context, optional 587 /// \return the elementwise natural log 588 ARROW_EXPORT 589 Result<Datum> Ln(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 590 ExecContext* ctx = NULLPTR); 591 592 /// \brief Get the log base 10 of a value. 593 /// 594 /// If argument is null the result will be null. 595 /// 596 /// \param[in] arg The values to compute the logarithm for. 597 /// \param[in] options arithmetic options (overflow handling), optional 598 /// \param[in] ctx the function execution context, optional 599 /// \return the elementwise log base 10 600 ARROW_EXPORT 601 Result<Datum> Log10(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 602 ExecContext* ctx = NULLPTR); 603 604 /// \brief Get the log base 2 of a value. 605 /// 606 /// If argument is null the result will be null. 607 /// 608 /// \param[in] arg The values to compute the logarithm for. 609 /// \param[in] options arithmetic options (overflow handling), optional 610 /// \param[in] ctx the function execution context, optional 611 /// \return the elementwise log base 2 612 ARROW_EXPORT 613 Result<Datum> Log2(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 614 ExecContext* ctx = NULLPTR); 615 616 /// \brief Get the natural log of (1 + value). 617 /// 618 /// If argument is null the result will be null. 619 /// This function may be more accurate than Log(1 + value) for values close to zero. 620 /// 621 /// \param[in] arg The values to compute the logarithm for. 622 /// \param[in] options arithmetic options (overflow handling), optional 623 /// \param[in] ctx the function execution context, optional 624 /// \return the elementwise natural log 625 ARROW_EXPORT 626 Result<Datum> Log1p(const Datum& arg, ArithmeticOptions options = ArithmeticOptions(), 627 ExecContext* ctx = NULLPTR); 628 629 /// \brief Get the log of a value to the given base. 630 /// 631 /// If argument is null the result will be null. 632 /// 633 /// \param[in] arg The values to compute the logarithm for. 634 /// \param[in] base The given base. 635 /// \param[in] options arithmetic options (overflow handling), optional 636 /// \param[in] ctx the function execution context, optional 637 /// \return the elementwise log to the given base 638 ARROW_EXPORT 639 Result<Datum> Logb(const Datum& arg, const Datum& base, 640 ArithmeticOptions options = ArithmeticOptions(), 641 ExecContext* ctx = NULLPTR); 642 643 /// \brief Round to the nearest integer less than or equal in magnitude to the 644 /// argument. 645 /// 646 /// If argument is null the result will be null. 647 /// 648 /// \param[in] arg the value to round 649 /// \param[in] ctx the function execution context, optional 650 /// \return the rounded value 651 ARROW_EXPORT 652 Result<Datum> Floor(const Datum& arg, ExecContext* ctx = NULLPTR); 653 654 /// \brief Round to the nearest integer greater than or equal in magnitude to the 655 /// argument. 656 /// 657 /// If argument is null the result will be null. 658 /// 659 /// \param[in] arg the value to round 660 /// \param[in] ctx the function execution context, optional 661 /// \return the rounded value 662 ARROW_EXPORT 663 Result<Datum> Ceil(const Datum& arg, ExecContext* ctx = NULLPTR); 664 665 /// \brief Get the integral part without fractional digits. 666 /// 667 /// If argument is null the result will be null. 668 /// 669 /// \param[in] arg the value to truncate 670 /// \param[in] ctx the function execution context, optional 671 /// \return the truncated value 672 ARROW_EXPORT 673 Result<Datum> Trunc(const Datum& arg, ExecContext* ctx = NULLPTR); 674 675 /// \brief Find the element-wise maximum of any number of arrays or scalars. 676 /// Array values must be the same length. 677 /// 678 /// \param[in] args arrays or scalars to operate on. 679 /// \param[in] options options for handling nulls, optional 680 /// \param[in] ctx the function execution context, optional 681 /// \return the element-wise maximum 682 ARROW_EXPORT 683 Result<Datum> MaxElementWise( 684 const std::vector<Datum>& args, 685 ElementWiseAggregateOptions options = ElementWiseAggregateOptions::Defaults(), 686 ExecContext* ctx = NULLPTR); 687 688 /// \brief Find the element-wise minimum of any number of arrays or scalars. 689 /// Array values must be the same length. 690 /// 691 /// \param[in] args arrays or scalars to operate on. 692 /// \param[in] options options for handling nulls, optional 693 /// \param[in] ctx the function execution context, optional 694 /// \return the element-wise minimum 695 ARROW_EXPORT 696 Result<Datum> MinElementWise( 697 const std::vector<Datum>& args, 698 ElementWiseAggregateOptions options = ElementWiseAggregateOptions::Defaults(), 699 ExecContext* ctx = NULLPTR); 700 701 /// \brief Get the sign of a value. Array values can be of arbitrary length. If argument 702 /// is null the result will be null. 703 /// 704 /// \param[in] arg the value to extract sign from 705 /// \param[in] ctx the function execution context, optional 706 /// \return the element-wise sign function 707 ARROW_EXPORT 708 Result<Datum> Sign(const Datum& arg, ExecContext* ctx = NULLPTR); 709 710 /// \brief Round a value to a given precision. 711 /// 712 /// If argument is null the result will be null. 713 /// 714 /// \param[in] arg the value rounded 715 /// \param[in] options rounding options (rounding mode and number of digits), optional 716 /// \param[in] ctx the function execution context, optional 717 /// \return the element-wise rounded value 718 ARROW_EXPORT 719 Result<Datum> Round(const Datum& arg, RoundOptions options = RoundOptions::Defaults(), 720 ExecContext* ctx = NULLPTR); 721 722 /// \brief Round a value to a given multiple. 723 /// 724 /// If argument is null the result will be null. 725 /// 726 /// \param[in] arg the value to round 727 /// \param[in] options rounding options (rounding mode and multiple), optional 728 /// \param[in] ctx the function execution context, optional 729 /// \return the element-wise rounded value 730 ARROW_EXPORT 731 Result<Datum> RoundToMultiple( 732 const Datum& arg, RoundToMultipleOptions options = RoundToMultipleOptions::Defaults(), 733 ExecContext* ctx = NULLPTR); 734 735 /// \brief Compare a numeric array with a scalar. 736 /// 737 /// \param[in] left datum to compare, must be an Array 738 /// \param[in] right datum to compare, must be a Scalar of the same type than 739 /// left Datum. 740 /// \param[in] options compare options 741 /// \param[in] ctx the function execution context, optional 742 /// \return resulting datum 743 /// 744 /// Note on floating point arrays, this uses ieee-754 compare semantics. 745 /// 746 /// \since 1.0.0 747 /// \note API not yet finalized 748 ARROW_DEPRECATED("Deprecated in 5.0.0. Use each compare function directly") 749 ARROW_EXPORT 750 Result<Datum> Compare(const Datum& left, const Datum& right, CompareOptions options, 751 ExecContext* ctx = NULLPTR); 752 753 /// \brief Invert the values of a boolean datum 754 /// \param[in] value datum to invert 755 /// \param[in] ctx the function execution context, optional 756 /// \return the resulting datum 757 /// 758 /// \since 1.0.0 759 /// \note API not yet finalized 760 ARROW_EXPORT 761 Result<Datum> Invert(const Datum& value, ExecContext* ctx = NULLPTR); 762 763 /// \brief Element-wise AND of two boolean datums which always propagates nulls 764 /// (null and false is null). 765 /// 766 /// \param[in] left left operand 767 /// \param[in] right right operand 768 /// \param[in] ctx the function execution context, optional 769 /// \return the resulting datum 770 /// 771 /// \since 1.0.0 772 /// \note API not yet finalized 773 ARROW_EXPORT 774 Result<Datum> And(const Datum& left, const Datum& right, ExecContext* ctx = NULLPTR); 775 776 /// \brief Element-wise AND of two boolean datums with a Kleene truth table 777 /// (null and false is false). 778 /// 779 /// \param[in] left left operand 780 /// \param[in] right right operand 781 /// \param[in] ctx the function execution context, optional 782 /// \return the resulting datum 783 /// 784 /// \since 1.0.0 785 /// \note API not yet finalized 786 ARROW_EXPORT 787 Result<Datum> KleeneAnd(const Datum& left, const Datum& right, 788 ExecContext* ctx = NULLPTR); 789 790 /// \brief Element-wise OR of two boolean datums which always propagates nulls 791 /// (null and true is null). 792 /// 793 /// \param[in] left left operand 794 /// \param[in] right right operand 795 /// \param[in] ctx the function execution context, optional 796 /// \return the resulting datum 797 /// 798 /// \since 1.0.0 799 /// \note API not yet finalized 800 ARROW_EXPORT 801 Result<Datum> Or(const Datum& left, const Datum& right, ExecContext* ctx = NULLPTR); 802 803 /// \brief Element-wise OR of two boolean datums with a Kleene truth table 804 /// (null or true is true). 805 /// 806 /// \param[in] left left operand 807 /// \param[in] right right operand 808 /// \param[in] ctx the function execution context, optional 809 /// \return the resulting datum 810 /// 811 /// \since 1.0.0 812 /// \note API not yet finalized 813 ARROW_EXPORT 814 Result<Datum> KleeneOr(const Datum& left, const Datum& right, ExecContext* ctx = NULLPTR); 815 816 /// \brief Element-wise XOR of two boolean datums 817 /// \param[in] left left operand 818 /// \param[in] right right operand 819 /// \param[in] ctx the function execution context, optional 820 /// \return the resulting datum 821 /// 822 /// \since 1.0.0 823 /// \note API not yet finalized 824 ARROW_EXPORT 825 Result<Datum> Xor(const Datum& left, const Datum& right, ExecContext* ctx = NULLPTR); 826 827 /// \brief Element-wise AND NOT of two boolean datums which always propagates nulls 828 /// (null and not true is null). 829 /// 830 /// \param[in] left left operand 831 /// \param[in] right right operand 832 /// \param[in] ctx the function execution context, optional 833 /// \return the resulting datum 834 /// 835 /// \since 3.0.0 836 /// \note API not yet finalized 837 ARROW_EXPORT 838 Result<Datum> AndNot(const Datum& left, const Datum& right, ExecContext* ctx = NULLPTR); 839 840 /// \brief Element-wise AND NOT of two boolean datums with a Kleene truth table 841 /// (false and not null is false, null and not true is false). 842 /// 843 /// \param[in] left left operand 844 /// \param[in] right right operand 845 /// \param[in] ctx the function execution context, optional 846 /// \return the resulting datum 847 /// 848 /// \since 3.0.0 849 /// \note API not yet finalized 850 ARROW_EXPORT 851 Result<Datum> KleeneAndNot(const Datum& left, const Datum& right, 852 ExecContext* ctx = NULLPTR); 853 854 /// \brief IsIn returns true for each element of `values` that is contained in 855 /// `value_set` 856 /// 857 /// Behaviour of nulls is governed by SetLookupOptions::skip_nulls. 858 /// 859 /// \param[in] values array-like input to look up in value_set 860 /// \param[in] options SetLookupOptions 861 /// \param[in] ctx the function execution context, optional 862 /// \return the resulting datum 863 /// 864 /// \since 1.0.0 865 /// \note API not yet finalized 866 ARROW_EXPORT 867 Result<Datum> IsIn(const Datum& values, const SetLookupOptions& options, 868 ExecContext* ctx = NULLPTR); 869 ARROW_EXPORT 870 Result<Datum> IsIn(const Datum& values, const Datum& value_set, 871 ExecContext* ctx = NULLPTR); 872 873 /// \brief IndexIn examines each slot in the values against a value_set array. 874 /// If the value is not found in value_set, null will be output. 875 /// If found, the index of occurrence within value_set (ignoring duplicates) 876 /// will be output. 877 /// 878 /// For example given values = [99, 42, 3, null] and 879 /// value_set = [3, 3, 99], the output will be = [2, null, 0, null] 880 /// 881 /// Behaviour of nulls is governed by SetLookupOptions::skip_nulls. 882 /// 883 /// \param[in] values array-like input 884 /// \param[in] options SetLookupOptions 885 /// \param[in] ctx the function execution context, optional 886 /// \return the resulting datum 887 /// 888 /// \since 1.0.0 889 /// \note API not yet finalized 890 ARROW_EXPORT 891 Result<Datum> IndexIn(const Datum& values, const SetLookupOptions& options, 892 ExecContext* ctx = NULLPTR); 893 ARROW_EXPORT 894 Result<Datum> IndexIn(const Datum& values, const Datum& value_set, 895 ExecContext* ctx = NULLPTR); 896 897 /// \brief IsValid returns true for each element of `values` that is not null, 898 /// false otherwise 899 /// 900 /// \param[in] values input to examine for validity 901 /// \param[in] ctx the function execution context, optional 902 /// \return the resulting datum 903 /// 904 /// \since 1.0.0 905 /// \note API not yet finalized 906 ARROW_EXPORT 907 Result<Datum> IsValid(const Datum& values, ExecContext* ctx = NULLPTR); 908 909 /// \brief IsNull returns true for each element of `values` that is null, 910 /// false otherwise 911 /// 912 /// \param[in] values input to examine for nullity 913 /// \param[in] options NullOptions 914 /// \param[in] ctx the function execution context, optional 915 /// \return the resulting datum 916 /// 917 /// \since 1.0.0 918 /// \note API not yet finalized 919 ARROW_EXPORT 920 Result<Datum> IsNull(const Datum& values, NullOptions options = NullOptions::Defaults(), 921 ExecContext* ctx = NULLPTR); 922 923 /// \brief IsNan returns true for each element of `values` that is NaN, 924 /// false otherwise 925 /// 926 /// \param[in] values input to look for NaN 927 /// \param[in] ctx the function execution context, optional 928 /// \return the resulting datum 929 /// 930 /// \since 3.0.0 931 /// \note API not yet finalized 932 ARROW_EXPORT 933 Result<Datum> IsNan(const Datum& values, ExecContext* ctx = NULLPTR); 934 935 /// \brief IfElse returns elements chosen from `left` or `right` 936 /// depending on `cond`. `null` values in `cond` will be promoted to the result 937 /// 938 /// \param[in] cond `Boolean` condition Scalar/ Array 939 /// \param[in] left Scalar/ Array 940 /// \param[in] right Scalar/ Array 941 /// \param[in] ctx the function execution context, optional 942 /// 943 /// \return the resulting datum 944 /// 945 /// \since 5.0.0 946 /// \note API not yet finalized 947 ARROW_EXPORT 948 Result<Datum> IfElse(const Datum& cond, const Datum& left, const Datum& right, 949 ExecContext* ctx = NULLPTR); 950 951 /// \brief CaseWhen behaves like a switch/case or if-else if-else statement: for 952 /// each row, select the first value for which the corresponding condition is 953 /// true, or (if given) select the 'else' value, else emit null. Note that a 954 /// null condition is the same as false. 955 /// 956 /// \param[in] cond Conditions (Boolean) 957 /// \param[in] cases Values (any type), along with an optional 'else' value. 958 /// \param[in] ctx the function execution context, optional 959 /// 960 /// \return the resulting datum 961 /// 962 /// \since 5.0.0 963 /// \note API not yet finalized 964 ARROW_EXPORT 965 Result<Datum> CaseWhen(const Datum& cond, const std::vector<Datum>& cases, 966 ExecContext* ctx = NULLPTR); 967 968 /// \brief Year returns year for each element of `values` 969 /// 970 /// \param[in] values input to extract year from 971 /// \param[in] ctx the function execution context, optional 972 /// \return the resulting datum 973 /// 974 /// \since 5.0.0 975 /// \note API not yet finalized 976 ARROW_EXPORT 977 Result<Datum> Year(const Datum& values, ExecContext* ctx = NULLPTR); 978 979 /// \brief Month returns month for each element of `values`. 980 /// Month is encoded as January=1, December=12 981 /// 982 /// \param[in] values input to extract month from 983 /// \param[in] ctx the function execution context, optional 984 /// \return the resulting datum 985 /// 986 /// \since 5.0.0 987 /// \note API not yet finalized 988 ARROW_EXPORT 989 Result<Datum> Month(const Datum& values, ExecContext* ctx = NULLPTR); 990 991 /// \brief Day returns day number for each element of `values` 992 /// 993 /// \param[in] values input to extract day from 994 /// \param[in] ctx the function execution context, optional 995 /// \return the resulting datum 996 /// 997 /// \since 5.0.0 998 /// \note API not yet finalized 999 ARROW_EXPORT 1000 Result<Datum> Day(const Datum& values, ExecContext* ctx = NULLPTR); 1001 1002 /// \brief DayOfWeek returns number of the day of the week value for each element of 1003 /// `values`. 1004 /// 1005 /// By default week starts on Monday denoted by 0 and ends on Sunday denoted 1006 /// by 6. Start day of the week (Monday=1, Sunday=7) and numbering base (0 or 1) can be 1007 /// set using DayOfWeekOptions 1008 /// 1009 /// \param[in] values input to extract number of the day of the week from 1010 /// \param[in] options for setting start of the week and day numbering 1011 /// \param[in] ctx the function execution context, optional 1012 /// \return the resulting datum 1013 /// 1014 /// \since 5.0.0 1015 /// \note API not yet finalized 1016 ARROW_EXPORT Result<Datum> DayOfWeek(const Datum& values, 1017 DayOfWeekOptions options = DayOfWeekOptions(), 1018 ExecContext* ctx = NULLPTR); 1019 1020 /// \brief DayOfYear returns number of day of the year for each element of `values`. 1021 /// January 1st maps to day number 1, February 1st to 32, etc. 1022 /// 1023 /// \param[in] values input to extract number of day of the year from 1024 /// \param[in] ctx the function execution context, optional 1025 /// \return the resulting datum 1026 /// 1027 /// \since 5.0.0 1028 /// \note API not yet finalized 1029 ARROW_EXPORT Result<Datum> DayOfYear(const Datum& values, ExecContext* ctx = NULLPTR); 1030 1031 /// \brief ISOYear returns ISO year number for each element of `values`. 1032 /// First week of an ISO year has the majority (4 or more) of its days in January. 1033 /// 1034 /// \param[in] values input to extract ISO year from 1035 /// \param[in] ctx the function execution context, optional 1036 /// \return the resulting datum 1037 /// 1038 /// \since 5.0.0 1039 /// \note API not yet finalized 1040 ARROW_EXPORT 1041 Result<Datum> ISOYear(const Datum& values, ExecContext* ctx = NULLPTR); 1042 1043 /// \brief ISOWeek returns ISO week of year number for each element of `values`. 1044 /// First ISO week has the majority (4 or more) of its days in January. 1045 /// ISO week starts on Monday. Year can have 52 or 53 weeks. 1046 /// Week numbering can start with 1. 1047 /// 1048 /// \param[in] values input to extract ISO week of year from 1049 /// \param[in] ctx the function execution context, optional 1050 /// \return the resulting datum 1051 /// 1052 /// \since 5.0.0 1053 /// \note API not yet finalized 1054 ARROW_EXPORT Result<Datum> ISOWeek(const Datum& values, ExecContext* ctx = NULLPTR); 1055 1056 /// \brief USWeek returns US week of year number for each element of `values`. 1057 /// First US week has the majority (4 or more) of its days in January. 1058 /// US week starts on Sunday. Year can have 52 or 53 weeks. 1059 /// Week numbering starts with 1. 1060 /// 1061 /// \param[in] values input to extract US week of year from 1062 /// \param[in] ctx the function execution context, optional 1063 /// \return the resulting datum 1064 /// 1065 /// \since 6.0.0 1066 /// \note API not yet finalized 1067 ARROW_EXPORT Result<Datum> USWeek(const Datum& values, ExecContext* ctx = NULLPTR); 1068 1069 /// \brief Week returns week of year number for each element of `values`. 1070 /// First ISO week has the majority (4 or more) of its days in January. 1071 /// Year can have 52 or 53 weeks. Week numbering can start with 0 or 1 1072 /// depending on DayOfWeekOptions.count_from_zero. 1073 /// 1074 /// \param[in] values input to extract week of year from 1075 /// \param[in] options for setting numbering start 1076 /// \param[in] ctx the function execution context, optional 1077 /// \return the resulting datum 1078 /// 1079 /// \since 6.0.0 1080 /// \note API not yet finalized 1081 ARROW_EXPORT Result<Datum> Week(const Datum& values, WeekOptions options = WeekOptions(), 1082 ExecContext* ctx = NULLPTR); 1083 1084 /// \brief ISOCalendar returns a (ISO year, ISO week, ISO day of week) struct for 1085 /// each element of `values`. 1086 /// ISO week starts on Monday denoted by 1 and ends on Sunday denoted by 7. 1087 /// 1088 /// \param[in] values input to ISO calendar struct from 1089 /// \param[in] ctx the function execution context, optional 1090 /// \return the resulting datum 1091 /// 1092 /// \since 5.0.0 1093 /// \note API not yet finalized 1094 ARROW_EXPORT Result<Datum> ISOCalendar(const Datum& values, ExecContext* ctx = NULLPTR); 1095 1096 /// \brief Quarter returns the quarter of year number for each element of `values` 1097 /// First quarter maps to 1 and fourth quarter maps to 4. 1098 /// 1099 /// \param[in] values input to extract quarter of year from 1100 /// \param[in] ctx the function execution context, optional 1101 /// \return the resulting datum 1102 /// 1103 /// \since 5.0.0 1104 /// \note API not yet finalized 1105 ARROW_EXPORT Result<Datum> Quarter(const Datum& values, ExecContext* ctx = NULLPTR); 1106 1107 /// \brief Hour returns hour value for each element of `values` 1108 /// 1109 /// \param[in] values input to extract hour from 1110 /// \param[in] ctx the function execution context, optional 1111 /// \return the resulting datum 1112 /// 1113 /// \since 5.0.0 1114 /// \note API not yet finalized 1115 ARROW_EXPORT 1116 Result<Datum> Hour(const Datum& values, ExecContext* ctx = NULLPTR); 1117 1118 /// \brief Minute returns minutes value for each element of `values` 1119 /// 1120 /// \param[in] values input to extract minutes from 1121 /// \param[in] ctx the function execution context, optional 1122 /// \return the resulting datum 1123 /// 1124 /// \since 5.0.0 1125 /// \note API not yet finalized 1126 ARROW_EXPORT 1127 Result<Datum> Minute(const Datum& values, ExecContext* ctx = NULLPTR); 1128 1129 /// \brief Second returns seconds value for each element of `values` 1130 /// 1131 /// \param[in] values input to extract seconds from 1132 /// \param[in] ctx the function execution context, optional 1133 /// \return the resulting datum 1134 /// 1135 /// \since 5.0.0 1136 /// \note API not yet finalized 1137 ARROW_EXPORT 1138 Result<Datum> Second(const Datum& values, ExecContext* ctx = NULLPTR); 1139 1140 /// \brief Millisecond returns number of milliseconds since the last full second 1141 /// for each element of `values` 1142 /// 1143 /// \param[in] values input to extract milliseconds from 1144 /// \param[in] ctx the function execution context, optional 1145 /// \return the resulting datum 1146 /// 1147 /// \since 5.0.0 1148 /// \note API not yet finalized 1149 ARROW_EXPORT 1150 Result<Datum> Millisecond(const Datum& values, ExecContext* ctx = NULLPTR); 1151 1152 /// \brief Microsecond returns number of microseconds since the last full millisecond 1153 /// for each element of `values` 1154 /// 1155 /// \param[in] values input to extract microseconds from 1156 /// \param[in] ctx the function execution context, optional 1157 /// \return the resulting datum 1158 /// 1159 /// \since 5.0.0 1160 /// \note API not yet finalized 1161 ARROW_EXPORT 1162 Result<Datum> Microsecond(const Datum& values, ExecContext* ctx = NULLPTR); 1163 1164 /// \brief Nanosecond returns number of nanoseconds since the last full millisecond 1165 /// for each element of `values` 1166 /// 1167 /// \param[in] values input to extract nanoseconds from 1168 /// \param[in] ctx the function execution context, optional 1169 /// \return the resulting datum 1170 /// 1171 /// \since 5.0.0 1172 /// \note API not yet finalized 1173 ARROW_EXPORT 1174 Result<Datum> Nanosecond(const Datum& values, ExecContext* ctx = NULLPTR); 1175 1176 /// \brief Subsecond returns the fraction of second elapsed since last full second 1177 /// as a float for each element of `values` 1178 /// 1179 /// \param[in] values input to extract subsecond from 1180 /// \param[in] ctx the function execution context, optional 1181 /// \return the resulting datum 1182 /// 1183 /// \since 5.0.0 1184 /// \note API not yet finalized 1185 ARROW_EXPORT Result<Datum> Subsecond(const Datum& values, ExecContext* ctx = NULLPTR); 1186 1187 /// \brief Format timestamps according to a format string 1188 /// 1189 /// Return formatted time strings according to the format string 1190 /// `StrftimeOptions::format` and to the locale specifier `Strftime::locale`. 1191 /// 1192 /// \param[in] values input timestamps 1193 /// \param[in] options for setting format string and locale 1194 /// \param[in] ctx the function execution context, optional 1195 /// \return the resulting datum 1196 /// 1197 /// \since 6.0.0 1198 /// \note API not yet finalized 1199 ARROW_EXPORT Result<Datum> Strftime(const Datum& values, StrftimeOptions options, 1200 ExecContext* ctx = NULLPTR); 1201 1202 /// \brief Converts timestamps from local timestamp without a timezone to a timestamp with 1203 /// timezone, interpreting the local timestamp as being in the specified timezone for each 1204 /// element of `values` 1205 /// 1206 /// \param[in] values input to convert 1207 /// \param[in] options for setting source timezone, exception and ambiguous timestamp 1208 /// handling. 1209 /// \param[in] ctx the function execution context, optional 1210 /// \return the resulting datum 1211 /// 1212 /// \since 6.0.0 1213 /// \note API not yet finalized 1214 ARROW_EXPORT Result<Datum> AssumeTimezone(const Datum& values, 1215 AssumeTimezoneOptions options, 1216 ExecContext* ctx = NULLPTR); 1217 1218 } // namespace compute 1219 } // namespace arrow 1220