red-arrow-flight-sql 13.0.0 → 14.0.1

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: e525a6ce012f2ed5e39f3753c92d4310d3e338cf8ad14cb2521513bcb9031e45
4
- data.tar.gz: bbd0a34d90d72f8618a174c1d44fd6c49b76793b7164750eaf89e6d4079f8dc0
3
+ metadata.gz: b3f60f22e7fa72b79a9ce10057081c7159cbae5d5f4201998fb67d527e2c6714
4
+ data.tar.gz: 3c9dfbcc05fc74b3fefd7ca6431f83d12fea9abd3422f2ae06b7c23d59c17b43
5
5
  SHA512:
6
- metadata.gz: b628f5f9be098d7f198fc6968eba772b1f08034391e1cccc2ffbab2c78c5a5906eb0c30e55b0f205533572c15aa0b4c5eb90b35f466b02a603df0da79998c0a4
7
- data.tar.gz: 941b59ad57580e1940cfbf85bbeac8773d7ce5df8d2f0d5cc11a1a9c3c8aa7c51e54a08ed203af166a03f6b2bf676fb241ddf9e707e27c64a2c8ffb58382868f
6
+ metadata.gz: 50038a8e3fbe80cd494e04288a84ddeacc8ec09aa00947ed13e653f9617281bf082c879d5a1e7dd837b562fae867542ed1b91529edf301213ea6791bf1c064b8
7
+ data.tar.gz: 68fdd9b8a7032e5194b479e6bd66d274cc13922569d2e462ed78cff742240dd6d6fa9e7a08b037d5cfd4666586854d78d371d3c1e552e5a19343b8c99fc61b80
@@ -0,0 +1,34 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ module ArrowFlightSQL
19
+ class Client
20
+ alias_method :prepare_raw, :prepare
21
+ def prepare(query, options=nil)
22
+ statement = prepare_raw(query, options)
23
+ if block_given?
24
+ begin
25
+ yield(statement)
26
+ ensure
27
+ statement.close(options) unless statement.closed?
28
+ end
29
+ else
30
+ statement
31
+ end
32
+ end
33
+ end
34
+ end
@@ -29,6 +29,7 @@ module ArrowFlightSQL
29
29
  end
30
30
 
31
31
  def require_libraries
32
+ require_relative "client"
32
33
  require_relative "server"
33
34
  end
34
35
 
@@ -16,7 +16,7 @@
16
16
  # under the License.
17
17
 
18
18
  module ArrowFlightSQL
19
- VERSION = "13.0.0"
19
+ VERSION = "14.0.1"
20
20
 
21
21
  module Version
22
22
  numbers, TAG = VERSION.split("-")
@@ -37,5 +37,36 @@ module Helper
37
37
  table = generator.page_view_table
38
38
  ArrowFlight::RecordBatchStream.new(table)
39
39
  end
40
+
41
+ def virtual_do_create_prepared_statement(context, request)
42
+ unless request.query == "INSERT INTO page_view_table VALUES ($1, true)"
43
+ raise Arrow::Error::Invalid.new("invalid SQL")
44
+ end
45
+ result = ArrowFlightSQL::CreatePreparedStatementResult.new
46
+ generator = InfoGenerator.new
47
+ table = generator.page_view_table
48
+ result.dataset_schema = table.schema
49
+ result.parameter_schema = table.schema.remove_field(1)
50
+ result.handle = "valid-handle"
51
+ result
52
+ end
53
+
54
+ def virtual_do_do_put_prepared_statement_update(context, command, reader)
55
+ unless command.handle.to_s == "valid-handle"
56
+ raise Arrow::Error::Invalid.new("invalid handle")
57
+ end
58
+ reader.read_all.n_rows
59
+ end
60
+
61
+ def virtual_do_close_prepared_statement(context, request)
62
+ unless request.handle.to_s == "valid-handle"
63
+ raise Arrow::Error::Invalid.new("invalid handle")
64
+ end
65
+ access_key = context.incoming_headers.assoc("x-access-key")
66
+ unless access_key == ["x-access-key", "secret"]
67
+ message = "invalid access key: #{access_key.inspect}"
68
+ raise Arrow::Error::Invalid.new(message)
69
+ end
70
+ end
40
71
  end
41
72
  end
data/test/test-client.rb CHANGED
@@ -39,4 +39,27 @@ class TestClient < Test::Unit::TestCase
39
39
  assert_equal(generator.page_view_table,
40
40
  reader.read_all)
41
41
  end
42
+
43
+ def test_prepare
44
+ insert_sql = "INSERT INTO page_view_table VALUES ($1, true)"
45
+ block_called = false
46
+ options = ArrowFlight::CallOptions.new
47
+ options.add_header("x-access-key", "secret")
48
+ @sql_client.prepare(insert_sql, options) do |statement|
49
+ block_called = true
50
+ assert_equal([
51
+ Arrow::Schema.new(count: :uint64, private: :boolean),
52
+ Arrow::Schema.new(count: :uint64),
53
+ ],
54
+ [
55
+ statement.dataset_schema,
56
+ statement.parameter_schema,
57
+ ])
58
+ counts = Arrow::UInt64Array.new([1, 2, 3])
59
+ parameters = Arrow::RecordBatch.new(count: counts)
60
+ statement.set_record_batch(parameters)
61
+ assert_equal(3, statement.execute_update)
62
+ end
63
+ assert_true(block_called)
64
+ end
42
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-arrow-flight-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.0.0
4
+ version: 14.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apache Arrow Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-28 00:00:00.000000000 Z
11
+ date: 2023-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: red-arrow-flight
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 13.0.0
19
+ version: 14.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 13.0.0
26
+ version: 14.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -82,6 +82,7 @@ files:
82
82
  - Rakefile
83
83
  - dependency-check/Rakefile
84
84
  - lib/arrow-flight-sql.rb
85
+ - lib/arrow-flight-sql/client.rb
85
86
  - lib/arrow-flight-sql/loader.rb
86
87
  - lib/arrow-flight-sql/server.rb
87
88
  - lib/arrow-flight-sql/version.rb