kou commented on code in PR #46926:
URL: https://github.com/apache/arrow/pull/46926#discussion_r2720940225
##########
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, how about `^` for `:at_start` and `$` for `:at_end`?
For example:
* `-column` -> `["column", :descending, null_placement]`
* `+column` -> `["column", :ascending, null_placement]`
* `-^column` -> ["column", :descending, :at_start]`
* `-$column` -> ["column", :descending, :at_end]`
* `+^column` -> ["column", :ascending, :at_start]`
* `+$column` -> ["column", :ascending, :at_end]`
* `^column` -> ["column", order, :at_start]`
* `$column` -> ["column", order, :at_end]`
##########
ruby/red-arrow/lib/arrow/sort-key.rb:
##########
@@ -46,16 +46,16 @@ class << self
# @return [Arrow::SortKey] A new suitable sort key.
#
# @since 4.0.0
- def resolve(target, order=nil)
+ def resolve(target, order=nil, null_placement = nil)
Review Comment:
```suggestion
def resolve(target, order=nil, null_placement=nil)
```
--
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]