sequel-snowflake 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +3 -3
- data/.github/workflows/ruby.yml +2 -2
- data/CHANGELOG.md +10 -4
- data/lib/sequel/adapters/shared/snowflake.rb +32 -0
- data/lib/sequel/adapters/snowflake.rb +3 -0
- data/lib/sequel-snowflake/version.rb +1 -1
- data/sequel-snowflake.gemspec +1 -0
- data/spec/sequel/adapters/snowflake_spec.rb +32 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba6e3849823d647dca41ee39a327c8c2e832bfc4f45ceb33d184ae06ed834c4
|
4
|
+
data.tar.gz: b04b7c352deb704dc3b08dda547fd6b52e0cecdb6fe52cc1f2abce3f4c4b8c3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f682678759afd025e0ca7a7fc87c1dcdf5aaeb4c39b31519453d4064e2a168e43488a8dad341020b189a5dd65b191e22a9df51654f7b3d0b5a869a8b08abf94f
|
7
|
+
data.tar.gz: 2b83a1c9bbea68cb0ae13497f1bb8b15d7ad767ab8b0a83f26c12b3ec753b70081a1d7c56bc89b78e9da8cbc5812bbb51df5ee09321071ff6698aa2f4b9adeb0
|
@@ -14,10 +14,10 @@ jobs:
|
|
14
14
|
|
15
15
|
steps:
|
16
16
|
- uses: actions/checkout@v2
|
17
|
-
- name: Set up Ruby
|
18
|
-
uses:
|
17
|
+
- name: Set up Ruby 3.1
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
19
|
with:
|
20
|
-
ruby-version:
|
20
|
+
ruby-version: 3.1
|
21
21
|
|
22
22
|
- name: Publish to RubyGems
|
23
23
|
run: |
|
data/.github/workflows/ruby.yml
CHANGED
@@ -19,7 +19,7 @@ jobs:
|
|
19
19
|
runs-on: ubuntu-latest
|
20
20
|
strategy:
|
21
21
|
matrix:
|
22
|
-
ruby-version: ['2.
|
22
|
+
ruby-version: ['2.7', '3.0', '3.1']
|
23
23
|
|
24
24
|
steps:
|
25
25
|
- uses: actions/checkout@v2
|
@@ -28,7 +28,7 @@ jobs:
|
|
28
28
|
- name: Install Snowflake ODBC driver
|
29
29
|
run: curl ${SNOWFLAKE_DRIVER_URL} -o snowflake_driver.deb && sudo dpkg -i snowflake_driver.deb
|
30
30
|
env:
|
31
|
-
SNOWFLAKE_DRIVER_URL: https://sfc-repo.snowflakecomputing.com/odbc/linux/
|
31
|
+
SNOWFLAKE_DRIVER_URL: https://sfc-repo.snowflakecomputing.com/odbc/linux/2.25.2/snowflake-odbc-2.25.2.x86_64.deb
|
32
32
|
- name: Set up Ruby
|
33
33
|
uses: ruby/setup-ruby@v1
|
34
34
|
with:
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
5
6
|
|
7
|
+
## 2.1.0 / 2022-06-17
|
8
|
+
* Add support for `EXPLAIN`.
|
6
9
|
|
7
|
-
|
10
|
+
## 2.0.0 / 2021-06-16
|
11
|
+
* Change LICENSE to MIT (open source).
|
12
|
+
* This gem is now tested against Rubies 2.6, 2.7, and 3.0.
|
8
13
|
|
14
|
+
## 1.0.0 / 2021-04-22 [Initial Release]
|
9
15
|
* Handle parsing Snowflake values for the following types:
|
10
16
|
* Numeric data types
|
11
17
|
* String data types
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Sequel
|
2
|
+
module Snowflake
|
3
|
+
Sequel::Database.set_shared_adapter_scheme(:snowflake, self)
|
4
|
+
|
5
|
+
module DatasetMethods
|
6
|
+
# Return an array of strings specifying a query explanation for a SELECT of the
|
7
|
+
# current dataset.
|
8
|
+
# The options (symbolized, in lowercase) are:
|
9
|
+
# JSON: JSON output is easier to store in a table and query.
|
10
|
+
# TABULAR (default): tabular output is generally more human-readable than JSON output.
|
11
|
+
# TEXT: formatted text output is generally more human-readable than JSON output.
|
12
|
+
def explain(opts=OPTS)
|
13
|
+
# Load the PrettyTable class, needed for explain output
|
14
|
+
Sequel.extension(:_pretty_table) unless defined?(Sequel::PrettyTable)
|
15
|
+
|
16
|
+
explain_with_format = if opts[:tabular]
|
17
|
+
"EXPLAIN USING TABULAR"
|
18
|
+
elsif opts[:json]
|
19
|
+
"EXPLAIN USING JSON"
|
20
|
+
elsif opts[:text]
|
21
|
+
"EXPLAIN USING TEXT"
|
22
|
+
else
|
23
|
+
"EXPLAIN"
|
24
|
+
end
|
25
|
+
|
26
|
+
ds = db.send(:metadata_dataset).clone(:sql=>"#{explain_with_format} #{select_sql}")
|
27
|
+
rows = ds.all
|
28
|
+
Sequel::PrettyTable.string(rows, ds.columns)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'sequel'
|
2
2
|
require 'sequel/adapters/odbc'
|
3
|
+
require_relative 'shared/snowflake'
|
3
4
|
|
4
5
|
# A lightweight adapter providing Snowflake support for the `sequel` gem.
|
5
6
|
# The only difference between this and the Sequel-provided ODBC adapter is
|
@@ -20,6 +21,8 @@ module Sequel
|
|
20
21
|
|
21
22
|
# A custom Sequel Dataset class crafted specifically to handle Snowflake results.
|
22
23
|
class Dataset < Sequel::ODBC::Dataset
|
24
|
+
include Sequel::Snowflake::DatasetMethods
|
25
|
+
|
23
26
|
def fetch_rows(sql)
|
24
27
|
execute(sql) do |s|
|
25
28
|
i = -1
|
data/sequel-snowflake.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Sequel::Snowflake::VERSION
|
9
9
|
spec.authors = ["Yesware, Inc"]
|
10
10
|
spec.email = ["engineering@yesware.com"]
|
11
|
+
spec.license = "MIT"
|
11
12
|
spec.summary = %q{Sequel adapter for Snowflake}
|
12
13
|
spec.description = spec.summary
|
13
14
|
spec.homepage = "https://github.com/Yesware/sequel-snowflake"
|
@@ -68,4 +68,36 @@ describe Sequel::Snowflake::Dataset do
|
|
68
68
|
expect(db[test_table].select(:n).all).to eq([{ n: 17 }, { n: 18 }])
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
describe '#explain' do
|
73
|
+
# Create a test table with a reasonably-random suffix
|
74
|
+
let!(:test_table) { "SEQUEL_SNOWFLAKE_SPECS_#{SecureRandom.hex(10)}".to_sym }
|
75
|
+
let!(:db) { Sequel.connect(adapter: :snowflake, drvconnect: ENV['SNOWFLAKE_CONN_STR']) }
|
76
|
+
|
77
|
+
before(:each) do
|
78
|
+
db.create_table(test_table, :temp => true) do
|
79
|
+
Numeric :id
|
80
|
+
String :name
|
81
|
+
String :email
|
82
|
+
String :title
|
83
|
+
end
|
84
|
+
|
85
|
+
db[test_table].insert(
|
86
|
+
{ id: 1, name: 'John Null', email: 'j.null@example.com', title: 'Software Tester' }
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
after(:each) do
|
91
|
+
db.drop_table(test_table)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should have explain output" do
|
95
|
+
query = db.fetch("SELECT * FROM #{test_table} WHERE ID=1;")
|
96
|
+
|
97
|
+
expect(query.explain).to be_a_kind_of(String)
|
98
|
+
expect(query.explain(:tabular=>true)).to be_a_kind_of(String)
|
99
|
+
expect(query.explain(:json=>true)).to be_a_kind_of(String)
|
100
|
+
expect(query.explain(:text=>true)).to be_a_kind_of(String)
|
101
|
+
end
|
102
|
+
end
|
71
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-snowflake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yesware, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -98,13 +98,15 @@ files:
|
|
98
98
|
- Rakefile
|
99
99
|
- lib/sequel-snowflake.rb
|
100
100
|
- lib/sequel-snowflake/version.rb
|
101
|
+
- lib/sequel/adapters/shared/snowflake.rb
|
101
102
|
- lib/sequel/adapters/snowflake.rb
|
102
103
|
- sequel-snowflake.gemspec
|
103
104
|
- spec/sequel/adapters/snowflake_spec.rb
|
104
105
|
- spec/snowflake_spec.rb
|
105
106
|
- spec/spec_helper.rb
|
106
107
|
homepage: https://github.com/Yesware/sequel-snowflake
|
107
|
-
licenses:
|
108
|
+
licenses:
|
109
|
+
- MIT
|
108
110
|
metadata: {}
|
109
111
|
post_install_message:
|
110
112
|
rdoc_options: []
|
@@ -121,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
123
|
- !ruby/object:Gem::Version
|
122
124
|
version: '0'
|
123
125
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.3.7
|
125
127
|
signing_key:
|
126
128
|
specification_version: 4
|
127
129
|
summary: Sequel adapter for Snowflake
|