red-arrow-flight-sql 13.0.0 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e525a6ce012f2ed5e39f3753c92d4310d3e338cf8ad14cb2521513bcb9031e45
4
- data.tar.gz: bbd0a34d90d72f8618a174c1d44fd6c49b76793b7164750eaf89e6d4079f8dc0
3
+ metadata.gz: 3edaa6d2d45fb6c78a565cb41d0786df654932e35e91615a95248076d77631d3
4
+ data.tar.gz: 980519b323808a7134d70aa1ea285901bc5b588001eda6cf6772b4ffefe487b4
5
5
  SHA512:
6
- metadata.gz: b628f5f9be098d7f198fc6968eba772b1f08034391e1cccc2ffbab2c78c5a5906eb0c30e55b0f205533572c15aa0b4c5eb90b35f466b02a603df0da79998c0a4
7
- data.tar.gz: 941b59ad57580e1940cfbf85bbeac8773d7ce5df8d2f0d5cc11a1a9c3c8aa7c51e54a08ed203af166a03f6b2bf676fb241ddf9e707e27c64a2c8ffb58382868f
6
+ metadata.gz: ee44d8f7f9ea9ddc5bf5eaf413af8be396f2983d844f3f7341e986035450d0ad431df370838e0265532ee97f446ec7722b9989a3d58b435765e3547b96e05ea4
7
+ data.tar.gz: ae7c613ce9bfcb085cbba33bd554666be820c00287f67a69e26bbb57ceff0e9b6a406114769f28bbf283b617b4843986b5cd1446ec9f7813f2bff0c9afe10398
@@ -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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apache Arrow Developers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-28 00:00:00.000000000 Z
11
+ date: 2023-11-08 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.0
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.0
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
@@ -95,7 +96,7 @@ homepage: https://arrow.apache.org/
95
96
  licenses:
96
97
  - Apache-2.0
97
98
  metadata: {}
98
- post_install_message:
99
+ post_install_message:
99
100
  rdoc_options: []
100
101
  require_paths:
101
102
  - lib
@@ -110,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  requirements: []
113
- rubygems_version: 3.3.5
114
- signing_key:
114
+ rubygems_version: 3.5.0.dev
115
+ signing_key:
115
116
  specification_version: 4
116
117
  summary: Red Arrow Flight SQL is the Ruby bindings of Apache Arrow Flight SQL
117
118
  test_files: