red-adbc 0.8.0 → 0.10.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: c015efd686d0e55012a771444c0393f208cb286c675ebf2a7d599cb06581f613
4
- data.tar.gz: ffe80b18c200a15fc6068468556d0703a991d45e222978440179f86d66eb723b
3
+ metadata.gz: ac0000667c7415f8ee8798c14ed39afafe0f261a3c4532a1eaa587c9c0c64a19
4
+ data.tar.gz: 6ac196ebbd3b0e8ff85c45162643236153c0d92b01e2a3d803abf620cf2bb3e9
5
5
  SHA512:
6
- metadata.gz: f3a999a7f52871272caa0faff4646360ca80643f2775c6ed62402d89cbf187a3511c24abf8d38ab06713f2c2ce13936e6310785815f7fd29703e729a10259c75
7
- data.tar.gz: 86a36800bb560a53ea2d57011f52f954450936ae04f4636e8d2decb3c56eb979756ef2cbecb1e5f17a5a01abc37e51c86d3c67e2119d4d7e2460b0d9bedbe491
6
+ metadata.gz: fd168666ba54b89fca29a446bc80cd71dab983471dfcef559ad8839adce7a8c58da817ea3c4b2c290a8aa55115724e91f91e4e3d8997aa3f2642984cd4dbff2d
7
+ data.tar.gz: ad914853fe4fe18a643b3dde325d7c2f1cbc8b1546aa113caca417446145fc132f7eaaaabcf3758a441f1049bdd34df630b8bcb7dacc60ca5ed6466e9359ce5c
@@ -34,12 +34,12 @@ end
34
34
  namespace :dependency do
35
35
  desc "Check dependency"
36
36
  task :check do
37
- unless PKGConfig.check_version?("adbc-glib",
37
+ unless PKGConfig.check_version?("adbc-arrow-glib",
38
38
  ADBC::Version::MAJOR,
39
39
  ADBC::Version::MINOR,
40
40
  ADBC::Version::MICRO)
41
- unless NativePackageInstaller.install(debian: "libadbc-glib-dev",
42
- redhat: "adbc-glib-devel")
41
+ unless NativePackageInstaller.install(debian: "libadbc-arrow-glib-dev",
42
+ redhat: "adbc-arrow-glib-devel")
43
43
  exit(false)
44
44
  end
45
45
  end
@@ -0,0 +1,65 @@
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 ADBCArrow
19
+ class Statement
20
+ extend ADBC::StatementOpenable
21
+ include ADBC::StatementOperations
22
+
23
+ alias_method :execute_raw, :execute
24
+ def execute(need_result: true)
25
+ _, reader, n_rows_affected = execute_raw(need_result)
26
+ if need_result
27
+ begin
28
+ if block_given?
29
+ yield(reader, n_rows_affected)
30
+ else
31
+ [reader.read_all, n_rows_affected]
32
+ end
33
+ end
34
+ else
35
+ if block_given?
36
+ yield(n_rows_affected)
37
+ else
38
+ n_rows_affected
39
+ end
40
+ end
41
+ end
42
+
43
+ alias_method :bind_raw, :bind
44
+ def bind(*args)
45
+ n_args = args.size
46
+ if block_given?
47
+ message = "wrong number of arguments (given #{n_args}, expected 1 with block)"
48
+ raise ArgumentError, message unless n_args == 1
49
+ values = args[0]
50
+ if values.is_a?(Arrow::Table)
51
+ values = Arrow::TableBatchReader.new(values)
52
+ end
53
+ if values.is_a?(Arrow::RecordBatchReader)
54
+ bind_stream(values)
55
+ yield
56
+ else
57
+ bind_raw(values)
58
+ yield
59
+ end
60
+ else
61
+ bind_raw(*args)
62
+ end
63
+ end
64
+ end
65
+ end
data/lib/adbc/loader.rb CHANGED
@@ -43,3 +43,22 @@ module ADBC
43
43
  end
44
44
  end
45
45
  end
46
+
47
+ module ADBCArrow
48
+ class Loader < GObjectIntrospection::Loader
49
+ class << self
50
+ def load
51
+ super("ADBCArrow", ADBCArrow)
52
+ end
53
+ end
54
+
55
+ private
56
+ def post_load(repository, namespace)
57
+ require_libraries
58
+ end
59
+
60
+ def require_libraries
61
+ require_relative "arrow-statement"
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,33 @@
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 ADBC
19
+ module StatementOpenable
20
+ def open(connection)
21
+ statement = new(connection)
22
+ if block_given?
23
+ begin
24
+ yield(statement)
25
+ ensure
26
+ statement.release
27
+ end
28
+ else
29
+ statement
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
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 ADBC
19
+ module StatementOperations
20
+ def ingest(table_name, values, mode: :create)
21
+ self.ingest_target_table = table_name
22
+ self.ingest_mode = mode
23
+ bind(values) do
24
+ execute(need_result: false)
25
+ end
26
+ end
27
+
28
+ def query(sql, &block)
29
+ self.sql_query = sql
30
+ execute(&block)
31
+ end
32
+ end
33
+ end
@@ -15,22 +15,13 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
+ require_relative "statement-openable"
19
+ require_relative "statement-operations"
20
+
18
21
  module ADBC
19
22
  class Statement
20
- class << self
21
- def open(connection)
22
- statement = new(connection)
23
- if block_given?
24
- begin
25
- yield(statement)
26
- ensure
27
- statement.release
28
- end
29
- else
30
- statement
31
- end
32
- end
33
- end
23
+ extend StatementOpenable
24
+ include StatementOperations
34
25
 
35
26
  alias_method :execute_raw, :execute
36
27
  def execute(need_result: true)
@@ -94,25 +85,5 @@ module ADBC
94
85
  bind_raw(*args)
95
86
  end
96
87
  end
97
-
98
- def ingest(table_name, values, mode: :create)
99
- insert = "INSERT INTO #{table_name} (" # TODO escape
100
- fields = values.schema.fields
101
- insert << fields.collect(&:name).join(", ")
102
- insert << ") VALUES ("
103
- insert << (["?"] * fields.size).join(", ")
104
- insert << ")"
105
- self.sql_query = insert
106
- self.ingest_target_table = table_name
107
- self.ingest_mode = mode
108
- bind(values) do
109
- execute(need_result: false)
110
- end
111
- end
112
-
113
- def query(sql, &block)
114
- self.sql_query = sql
115
- execute(&block)
116
- end
117
88
  end
118
89
  end
data/lib/adbc/version.rb CHANGED
@@ -16,7 +16,7 @@
16
16
  # under the License.
17
17
 
18
18
  module ADBC
19
- VERSION = "0.8.0"
19
+ VERSION = "0.10.0"
20
20
 
21
21
  module Version
22
22
  MAJOR, MINOR, MICRO, TAG = VERSION.split(".").collect(&:to_i)
data/lib/adbc.rb CHANGED
@@ -24,6 +24,16 @@ require "adbc/loader"
24
24
  module ADBC
25
25
  class Error < StandardError
26
26
  end
27
+ end
27
28
 
28
- Loader.load
29
+ ADBC::Loader.load
30
+ begin
31
+ ADBCArrow::Loader.load
32
+ rescue GObjectIntrospection::RepositoryError
33
+ else
34
+ module ADBC
35
+ RawStatement = Statement
36
+ remove_const(:Statement)
37
+ Statement = ADBCArrow::Statement
38
+ end
29
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-adbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
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-11-09 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: red-arrow
@@ -38,9 +38,12 @@ files:
38
38
  - README.md
39
39
  - dependency-check/Rakefile
40
40
  - lib/adbc.rb
41
+ - lib/adbc/arrow-statement.rb
41
42
  - lib/adbc/connection.rb
42
43
  - lib/adbc/database.rb
43
44
  - lib/adbc/loader.rb
45
+ - lib/adbc/statement-openable.rb
46
+ - lib/adbc/statement-operations.rb
44
47
  - lib/adbc/statement.rb
45
48
  - lib/adbc/version.rb
46
49
  homepage: https://arrow.apache.org/