Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
data_drain (0.5.0)
data_drain (0.5.1)
activemodel (>= 6.0)
aws-sdk-glue (~> 1.0)
aws-sdk-s3 (~> 1.114)
Expand Down
5 changes: 4 additions & 1 deletion lib/data_drain/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ class << self
# @param partitions [Hash]
# @return [String]
def build_query_path(partitions)
partition_path = partition_keys.map { |k| "#{k}=#{partitions[k.to_sym] || partitions[k.to_s]}" }.join("/")
partition_path = partition_keys.map do |k|
val = partitions.key?(k.to_sym) ? partitions[k.to_sym] : partitions[k.to_s]
val.nil? || val.to_s.empty? ? "#{k}=*" : "#{k}=#{val}"
end.join("/")
DataDrain::Storage.adapter.build_path(bucket, folder_name, partition_path)
end

Expand Down
18 changes: 18 additions & 0 deletions spec/data_drain/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,23 @@
expect(path).to include("year=2026")
expect(path).to include("month=3")
end

it "usa wildcard cuando falta una partition key" do
path = record_class.send(:build_query_path, { year: 2026 })
expect(path).to include("year=2026")
expect(path).to include("month=*")
end

it "usa wildcards para todas las partition keys faltantes" do
path = record_class.send(:build_query_path, {})
expect(path).to include("year=*")
expect(path).to include("month=*")
end

it "trata valor cero (falsy) como valor legitimo, no como ausente" do
path = record_class.send(:build_query_path, { year: 2026, month: 0 })
expect(path).to include("year=2026")
expect(path).to include("month=0")
end
end
end
Loading