red-adbc 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependency-check/Rakefile +3 -3
- data/lib/adbc/arrow-statement.rb +65 -0
- data/lib/adbc/loader.rb +19 -0
- data/lib/adbc/statement-openable.rb +33 -0
- data/lib/adbc/statement-operations.rb +33 -0
- data/lib/adbc/statement.rb +5 -34
- data/lib/adbc/version.rb +1 -1
- data/lib/adbc.rb +11 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac0000667c7415f8ee8798c14ed39afafe0f261a3c4532a1eaa587c9c0c64a19
|
4
|
+
data.tar.gz: 6ac196ebbd3b0e8ff85c45162643236153c0d92b01e2a3d803abf620cf2bb3e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd168666ba54b89fca29a446bc80cd71dab983471dfcef559ad8839adce7a8c58da817ea3c4b2c290a8aa55115724e91f91e4e3d8997aa3f2642984cd4dbff2d
|
7
|
+
data.tar.gz: ad914853fe4fe18a643b3dde325d7c2f1cbc8b1546aa113caca417446145fc132f7eaaaabcf3758a441f1049bdd34df630b8bcb7dacc60ca5ed6466e9359ce5c
|
data/dependency-check/Rakefile
CHANGED
@@ -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
|
data/lib/adbc/statement.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
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
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
|
-
|
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.
|
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: 2024-
|
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/
|