Fokko commented on code in PR #36846:
URL: https://github.com/apache/arrow/pull/36846#discussion_r1339221494
##########
cpp/src/arrow/type.h:
##########
@@ -397,14 +397,76 @@ class ARROW_EXPORT Field : public detail::Fingerprintable,
/// \brief Options that control the behavior of `MergeWith`.
/// Options are to be added to allow type conversions, including integer
/// widening, promotion from integer to float, or conversion to or from
boolean.
- struct MergeOptions {
+ struct ARROW_EXPORT MergeOptions : public
util::ToStringOstreamable<MergeOptions> {
/// If true, a Field of NullType can be unified with a Field of another
type.
/// The unified field will be of the other type and become nullable.
/// Nullability will be promoted to the looser option (nullable if one is
not
/// nullable).
bool promote_nullability = true;
+ /// Allow a decimal to be unified with another decimal of the same
+ /// width, adjusting scale and precision as appropriate. May fail
+ /// if the adjustment is not possible.
+ bool promote_decimal = false;
+
+ /// Allow a decimal to be promoted to a float. The float type will
+ /// not itself be promoted (e.g. Decimal128 + Float32 = Float32).
+ bool promote_decimal_to_float = false;
+
+ /// Allow an integer to be promoted to a decimal.
+ ///
+ /// May fail if the decimal has insufficient precision to
+ /// accommodate the integer. (See increase_decimal_precision.)
+ bool promote_integer_to_decimal = false;
+
+ /// Allow an integer of a given bit width to be promoted to a
+ /// float; the result will be a float of an equal or greater bit
+ /// width to both of the inputs. Examples:
+ /// - int8 + float32 = float32
+ /// - int32 + float32 = float64
+ /// - int32 + float64 = float64
+ /// Because an int32 cannot always be represented exactly in the
+ /// 24 bits of a float32 mantissa.
+ bool promote_integer_to_float = false;
+
+ /// Allow an unsigned integer of a given bit width to be promoted
+ /// to a signed integer that fits into the signed type:
+ /// uint + int16 = int16
+ /// When widening is needed, set promote_numeric_width to true:
+ /// uint16 + int16 = int32
Review Comment:
That's correct, and has been fixed now 👍
##########
cpp/src/arrow/type.h:
##########
@@ -397,14 +397,76 @@ class ARROW_EXPORT Field : public detail::Fingerprintable,
/// \brief Options that control the behavior of `MergeWith`.
/// Options are to be added to allow type conversions, including integer
/// widening, promotion from integer to float, or conversion to or from
boolean.
- struct MergeOptions {
+ struct ARROW_EXPORT MergeOptions : public
util::ToStringOstreamable<MergeOptions> {
/// If true, a Field of NullType can be unified with a Field of another
type.
/// The unified field will be of the other type and become nullable.
/// Nullability will be promoted to the looser option (nullable if one is
not
/// nullable).
bool promote_nullability = true;
+ /// Allow a decimal to be unified with another decimal of the same
+ /// width, adjusting scale and precision as appropriate. May fail
+ /// if the adjustment is not possible.
+ bool promote_decimal = false;
+
+ /// Allow a decimal to be promoted to a float. The float type will
+ /// not itself be promoted (e.g. Decimal128 + Float32 = Float32).
+ bool promote_decimal_to_float = false;
+
+ /// Allow an integer to be promoted to a decimal.
+ ///
+ /// May fail if the decimal has insufficient precision to
+ /// accommodate the integer. (See increase_decimal_precision.)
+ bool promote_integer_to_decimal = false;
+
+ /// Allow an integer of a given bit width to be promoted to a
+ /// float; the result will be a float of an equal or greater bit
+ /// width to both of the inputs. Examples:
+ /// - int8 + float32 = float32
+ /// - int32 + float32 = float64
+ /// - int32 + float64 = float64
+ /// Because an int32 cannot always be represented exactly in the
+ /// 24 bits of a float32 mantissa.
+ bool promote_integer_to_float = false;
+
+ /// Allow an unsigned integer of a given bit width to be promoted
+ /// to a signed integer that fits into the signed type:
+ /// uint + int16 = int16
+ /// When widening is needed, set promote_numeric_width to true:
+ /// uint16 + int16 = int32
Review Comment:
That's correct, and has been fixed now 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]