hexspace 0.2.2 → 0.4.0

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: 3d21bbeba05778ebceedf12cde6444e13c651aa1e4046a6959255d2e9f38aa26
4
- data.tar.gz: e2aa5546583c0d7c5030b29e4fdca0cbb7caa013a00eafe51ba997b6fe576091
3
+ metadata.gz: 662a45aba18fe6a936d6ce153a590237330def782ad7a82e0ce2d0934f528c2c
4
+ data.tar.gz: 5f996fbe8ab11c0a44b7a1a2ce71670fef27ec0285cbd6e0a956427fa136e530
5
5
  SHA512:
6
- metadata.gz: cd5eaa3d37ce89e12a2b655a252c543e6c3c430230f764b0e34742c48221af6a68170e58e04d9620a03f46fc626d1065c1a1f1ecda957f21ad12d9bcb0810abc
7
- data.tar.gz: d4ddeb31b86a14dea33cc7ca798aca9e5af788f04b7e194c88dc0e21e503082bef7c4c1562c02fc4df9e1b2e4832af8e09a523a338ca5e54935f5a8ac5ee3d69
6
+ metadata.gz: 89dd9a8744ab44690461993c6149ea31249f5ef5ebdcf0003b36d2203ebc973f5e84c9ed298136c33beacceec18b2693b704d0abcbd24887bf5df4165142bf2e
7
+ data.tar.gz: 1310f8d984c6bc0fd5af5941b6287583c291961c3f12af1205a09654c0e200e15399ad044f17734da96cda4be7b27f0934fd3deddc3d5939456ad2dfd42e9bf7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.4.0 (2026-10-14)
2
+
3
+ - Changed `execute` method to return `Result` object by default
4
+ - Dropped support for Ruby < 3.3
5
+
6
+ ## 0.3.0 (2025-04-03)
7
+
8
+ - Dropped support for Ruby < 3.2
9
+
1
10
  ## 0.2.2 (2024-12-29)
2
11
 
3
12
  - Added support for Ruby 3.4
data/README.md CHANGED
@@ -23,7 +23,11 @@ client = Hexspace::Client.new
23
23
  Execute queries
24
24
 
25
25
  ```ruby
26
- client.execute("SELECT COUNT(*) FROM users")
26
+ result = client.execute("SELECT COUNT(*) FROM users")
27
+ result.rows
28
+ result.columns
29
+ result.column_types
30
+ result.to_a
27
31
  ```
28
32
 
29
33
  ## Connection Options
@@ -54,16 +58,6 @@ Set a timeout
54
58
  client.execute(statement, timeout: 10)
55
59
  ```
56
60
 
57
- Get a `Hexspace::Result` object instead of an array of hashes
58
-
59
- ```ruby
60
- result = client.execute(statement, result_object: true)
61
- result.rows
62
- result.columns
63
- result.column_types
64
- result.to_a
65
- ```
66
-
67
61
  ## Spark SQL Setup
68
62
 
69
63
  Download [Apache Spark](https://spark.apache.org/downloads.html) and start the [Thift server](https://spark.apache.org/docs/latest/sql-distributed-sql-engine.html).
@@ -25,7 +25,7 @@ module Hexspace
25
25
  uri = uri_class.build(host: host, port: port || 10001, path: "/cliservice")
26
26
 
27
27
  t = Thrift::HTTPClientTransport.new(uri)
28
- t.add_headers({"Authorization" => "Basic #{Base64.strict_encode64("#{username}:#{password}")}"})
28
+ t.add_headers({"Authorization" => "Basic #{["#{username}:#{password}"].pack("m0")}"})
29
29
  t
30
30
  else
31
31
  raise ArgumentError, "Invalid mode: #{mode}"
@@ -48,7 +48,7 @@ module Hexspace
48
48
  ObjectSpace.define_finalizer(self, self.class.finalize(@transport, @client, @session))
49
49
  end
50
50
 
51
- def execute(statement, timeout: nil, result_object: false)
51
+ def execute(statement, timeout: nil, result_object: true)
52
52
  result = execute_statement(statement, timeout: timeout)
53
53
  if result.operationHandle.hasResultSet
54
54
  result = process_result(result)
@@ -107,7 +107,6 @@ module Hexspace
107
107
 
108
108
  # columns can be nil with Spark 3.4+
109
109
  result.results.columns&.each_with_index do |col, j|
110
- name = columns[j]
111
110
  value = col.get_value
112
111
 
113
112
  if j == 0
@@ -1,5 +1,7 @@
1
1
  module Hexspace
2
2
  class Result
3
+ include Enumerable
4
+
3
5
  attr_reader :rows, :columns, :column_types
4
6
 
5
7
  def initialize(rows, columns, column_types)
@@ -8,9 +10,9 @@ module Hexspace
8
10
  @column_types = column_types
9
11
  end
10
12
 
11
- def to_a
12
- @rows.map do |row|
13
- @columns.zip(row).to_h
13
+ def each
14
+ @rows.each do |row|
15
+ yield @columns.zip(row).to_h
14
16
  end
15
17
  end
16
18
  end