chalk_ruby 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be8baa09bb22ab16fe18d5d82d89fa4d5ca75f2216f60daeb240ee185aecafc1
4
- data.tar.gz: 07cfafd2ff5de2898f492697f17eba513e5cdea23df58ed8489b637c3a5b6b40
3
+ metadata.gz: 4165478b519e054426f89a0e2a5baa7a8f1ef2e4eb3d23a4489bb478e96adca2
4
+ data.tar.gz: c51633a4a2a3ee79dfb2f1a22d9bf80d9a6c8719f587f71d894b7be877f1fa91
5
5
  SHA512:
6
- metadata.gz: befc8666980d27db057207bcf38a97e8f347879ed0938a9f8a5fcd3cbb07fe06d00e458ec50b7a54c0f308ab1f8ad2c331abe5c63213acde8073e04954ae1442
7
- data.tar.gz: b8fdb9a0157d03e68047bcc5da8ecd569441cbc60c93f9b42378c6a227a401b99b0a3eede639f5ec1bcf44891193fc619ea3ca7e5e64bc470e8cf40eeec3dc31
6
+ metadata.gz: 3a52b774af1729f1ba7194c97aa9ba8b323b3bbb47efe06dd9e8cfd5124e3fe963eb5fab5ecf698614cc9a3f4ae6aa09a65c6ff1f770f0d0ae6e257be80a1036
7
+ data.tar.gz: a4f91f89f52e8b3b036e3d19c1dde26845e430fa69e766cf88e0e7122f5a12f2750c8d689bfa7cdfc5d6094b307b608a8d79aeec9c5df0c462cf7a19450e38aa
@@ -469,26 +469,55 @@ module ChalkRuby
469
469
  end
470
470
 
471
471
  def to_feather(input_hash)
472
- unless red_arrow_available?
473
- raise NotImplementedError, "to_feather requires the 'red-arrow' gem. Please add it to your Gemfile: gem 'red-arrow', '~> 18.0.0'"
474
- end
472
+ raise NotImplementedError,
473
+ "Add `gem 'red-arrow', '~> 18.0'` to your Gemfile" unless red_arrow_available?
474
+
475
475
  require 'arrow'
476
476
 
477
- # Ensure all values in the input hash are arrays
478
- array_input_hash = input_hash.transform_values { |v| v.is_a?(Array) ? v : [v] }
477
+ # Normalise column data
478
+ array_input_hash = input_hash.transform_keys(&:to_s)
479
+ .transform_values { |v| v.is_a?(Array) ? v : [v] }
479
480
 
480
- # Create a table from the transformed input hash
481
- table = Arrow::Table.new(array_input_hash)
481
+ lengths = array_input_hash.values.map(&:length).uniq
482
+ raise ArgumentError, "Columns must be the same length (got #{lengths})" unless lengths.one?
482
483
 
483
- # Write to feather format in memory
484
- buffer = Arrow::ResizableBuffer.new(0)
484
+ table = Arrow::Table.new(array_input_hash)
485
485
 
486
+ buffer = Arrow::ResizableBuffer.new(0)
486
487
  output = Arrow::BufferOutputStream.new(buffer)
487
488
 
489
+ # ──────────────────────────────────────────────────────────
488
490
  table.write_as_feather(output)
491
+ output.close # ← **critical**: flush footer
492
+ # ──────────────────────────────────────────────────────────
489
493
 
490
- # Remove trailing null bytes from the resizable buffer; the buffer is 512 aligned
491
- buffer.data.to_s.b.gsub(/ARROW1(.*)ARROW1.*/m) {"ARROW1#{$1}ARROW1"}
494
+ # The stream writes exactly `output.tell` bytes; slice to that.
495
+ bytes_written = output.tell
496
+ buffer.data.to_s.b.byteslice(0, bytes_written)
492
497
  end
493
498
  end
499
+
500
+ # def to_feather(input_hash)
501
+ # unless red_arrow_available?
502
+ # raise NotImplementedError, "to_feather requires the 'red-arrow' gem. Please add it to your Gemfile: gem 'red-arrow', '~> 18.0.0'"
503
+ # end
504
+ # require 'arrow'
505
+ #
506
+ # # Ensure all values in the input hash are arrays
507
+ # array_input_hash = input_hash.transform_values { |v| v.is_a?(Array) ? v : [v] }
508
+ #
509
+ # # Create a table from the transformed input hash
510
+ # table = Arrow::Table.new(array_input_hash)
511
+ #
512
+ # # Write to feather format in memory
513
+ # buffer = Arrow::ResizableBuffer.new(0)
514
+ #
515
+ # output = Arrow::BufferOutputStream.new(buffer)
516
+ #
517
+ # table.write_as_feather(output)
518
+ #
519
+ # # Remove trailing null bytes from the resizable buffer; the buffer is 512 aligned
520
+ # buffer.data.to_s.b.gsub(/ARROW1(.*)ARROW1.*/m) {"ARROW1#{$1}ARROW1"}
521
+ # end
522
+ # end
494
523
  end
@@ -1,3 +1,3 @@
1
1
  module ChalkRuby
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
@@ -3,8 +3,8 @@ require 'rspec/autorun'
3
3
  require 'chalk_ruby/client'
4
4
  require 'chalk_ruby/error'
5
5
 
6
- CLIENT_ID = ''
7
- CLIENT_SECRET = ''
6
+ CLIENT_ID = 'client-9314816c664be6cb04678e5e3d0e50e2'
7
+ CLIENT_SECRET = 'secret-51f3ce3d4f701f23afdd622015732edf1eb62d0d678b3511b615f9b1f00b4a7d'
8
8
 
9
9
  RSpec.describe 'Online query' do
10
10
  it 'should accept valid queries' do
@@ -14,6 +14,8 @@ require 'chalk_ruby/protos/chalk/engine/v1/query_server_services_pb'
14
14
  require 'arrow'
15
15
 
16
16
 
17
+ CLIENT_ID = 'client-9314816c664be6cb04678e5e3d0e50e2'
18
+ CLIENT_SECRET = 'secret-51f3ce3d4f701f23afdd622015732edf1eb62d0d678b3511b615f9b1f00b4a7d'
17
19
 
18
20
 
19
21
  RSpec.describe ChalkRuby::GrpcClient do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chalk_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chalk AI, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-08 00:00:00.000000000 Z
11
+ date: 2025-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler