Taepper commented on code in PR #46926:
URL: https://github.com/apache/arrow/pull/46926#discussion_r2723865795
##########
ruby/red-arrow/lib/arrow/sort-key.rb:
##########
@@ -156,32 +157,49 @@ def initialize(target, order=nil)
#
# @since 4.0.0
def to_s
- if order == SortOrder::ASCENDING
+ result = if order == SortOrder::ASCENDING
"+#{target}"
else
"-#{target}"
end
+ if null_placement == NullPlacement::AT_START
+ result += "_at_start"
+ else
+ result += "_at_end"
+ end
+ return result
end
# For backward compatibility
alias_method :name, :target
private
- def normalize_target(target, order)
+ def normalize_target(target, order, null_placement)
+ # for recreatable, we should remove suffix
+ if target.end_with?("_at_start")
+ suffix_length = "_at_start".length
+ target = target[0..-(suffix_length + 1)]
+ elsif target.end_with?("_at_end")
+ suffix_length = "_at_end".length
+ target = target[0..-(suffix_length + 1)]
+ end
Review Comment:
Hmm, maybe this was a bad idea, I just noticed that this makes them no
longer safely round-trip. E.g.:
```
Arrow::SortKey.new(
# Inner key will printed as "+^count"
Arrow::SortKey.new(
"^count",
Arrow::SortOrder::ASCENDING,
Arrow::NullPlacement::AtEnd
).to_s
)
```
will have a null_placement of `AtStart`
--
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]