Skip to content

Commit 62c607c

Browse files
committed
Import
0 parents  commit 62c607c

File tree

17 files changed

+535
-0
lines changed

17 files changed

+535
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/test.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
name: "Ruby ${{ matrix.ruby-version }}: ${{ matrix.runs-on }}"
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
ruby-version:
14+
- "3.0"
15+
- "3.1"
16+
- "3.2"
17+
runs-on:
18+
- macos-latest
19+
- ubuntu-latest
20+
# - windows-latest
21+
runs-on: ${{ matrix.runs-on }}
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Prepare the Apache Arrow APT repository
25+
if: |
26+
runner.os == 'Linux'
27+
run: |
28+
sudo apt update
29+
sudo apt install -y -V ca-certificates lsb-release wget
30+
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
31+
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
32+
sudo apt update
33+
- uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: ${{ matrix.ruby-version }}
36+
bundler-cache: true
37+
- name: Test
38+
run: |
39+
bundle exec rake

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Gemfile.lock

Gemfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- ruby -*-
2+
3+
source "https://rubygems.org/"
4+
5+
gemspec
6+
7+
gem "bundler"
8+
gem "rake"
9+
gem "test-unit"
10+
11+
local_rails = File.expand_path(File.join(__dir__, "..", "rails"))
12+
if File.exist?(local_rails)
13+
path local_rails do
14+
gem "activerecord"
15+
end
16+
else
17+
git "https://github.com/rails/rails.git" do
18+
gem "activerecord"
19+
end
20+
end
21+
22+
local_adbc = File.expand_path(File.join(__dir__, "..", "arrow-adbc"))
23+
if File.exist?(local_adbc)
24+
path "#{local_adbc}/ruby" do
25+
gem "red-adbc"
26+
end
27+
else
28+
git "https://github.com/apache/arrow-adbc.git" do
29+
gem "red-adbc"
30+
end
31+
end

LICENSE.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2023 Sutou Kouhei <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Active Record ADBC adapter
2+
3+
## Description
4+
5+
Active Record ADBC adapter provides an ADBC adapter for Active Record.
6+
7+
This adapter is optimized for extracting and loading large data
8+
from/to DBs. The optimization is powered by Apache Arrow.
9+
10+
## Install
11+
12+
TODO
13+
14+
## Usage
15+
16+
TODO
17+
18+
## License
19+
20+
The MIT license. See `LICENSE.txt` for details.

Rakefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- ruby -*-
2+
3+
require "rubygems"
4+
require "bundler/gem_helper"
5+
6+
base_dir = File.join(__dir__)
7+
8+
helper = Bundler::GemHelper.new(base_dir)
9+
helper.install
10+
11+
release_task = Rake::Task["release"]
12+
release_task.prerequisites.replace(["build", "release:rubygem_push"])
13+
14+
desc "Run tests"
15+
task :test do
16+
cd(base_dir) do
17+
ruby("test/run.rb")
18+
end
19+
end
20+
21+
task default: :test

activerecord-adbc-adapter.gemspec

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- ruby -*-
2+
3+
require "fileutils"
4+
5+
require_relative "lib/activerecord-adbc-adapter/version"
6+
7+
Gem::Specification.new do |spec|
8+
spec.name = "activerecord-adbc-adapter"
9+
spec.version = ActiveRecordADBCAdapter::VERSION
10+
spec.homepage = "https://github.com/red-data-tools/activerecord-adbc-adapter"
11+
spec.authors = ["Sutou Kouhei"]
12+
spec.email = ["[email protected]"]
13+
14+
spec.summary = "Active Record's ADBC adapter"
15+
spec.description =
16+
"This gem provides an ADBC adapter for Active Record. " +
17+
"This adapter is optimized for extracting and loading large data " +
18+
"from/to DBs. The optimization is powered by Apache Arrow."
19+
spec.license = "MIT"
20+
spec.files = [
21+
"LICENSE.txt",
22+
"README.md",
23+
]
24+
spec.files += Dir.glob("lib/**/*.rb")
25+
26+
spec.add_runtime_dependency("activerecord")
27+
spec.add_runtime_dependency("red-arrow")
28+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module ActiveRecord
2+
module ConnectionAdapters
3+
module ADBC
4+
class Column < ConnectionAdapters::Column # :nodoc:
5+
end
6+
end
7+
end
8+
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module ActiveRecord
2+
module ConnectionAdapters
3+
module ADBC
4+
module DatabaseStatements
5+
def internal_exec_query(sql,
6+
name = "SQL",
7+
binds = [],
8+
prepare: false,
9+
async: false,
10+
allow_retry: false,
11+
materialize_transactions: true) # :nodoc:
12+
casted_binds = type_casted_binds(binds)
13+
log(sql, name, binds, casted_binds, async: async) do
14+
with_raw_connection do |conn|
15+
build_arrow_result(conn.query(sql, casted_binds))
16+
end
17+
end
18+
end
19+
end
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)