dwh 0.1.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 +7 -0
- data/.rubocop.yml +36 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +21 -0
- data/README.md +130 -0
- data/Rakefile +42 -0
- data/docs/DWH/Adapters/Adapter.html +3053 -0
- data/docs/DWH/Adapters/Athena.html +1704 -0
- data/docs/DWH/Adapters/Boolean.html +121 -0
- data/docs/DWH/Adapters/Druid.html +1626 -0
- data/docs/DWH/Adapters/DuckDb.html +2012 -0
- data/docs/DWH/Adapters/MySql.html +1704 -0
- data/docs/DWH/Adapters/OpenAuthorizable/ClassMethods.html +265 -0
- data/docs/DWH/Adapters/OpenAuthorizable.html +1102 -0
- data/docs/DWH/Adapters/Postgres.html +2000 -0
- data/docs/DWH/Adapters/Snowflake.html +1662 -0
- data/docs/DWH/Adapters/SqlServer.html +2084 -0
- data/docs/DWH/Adapters/Trino.html +1835 -0
- data/docs/DWH/Adapters.html +129 -0
- data/docs/DWH/AuthenticationError.html +142 -0
- data/docs/DWH/Behaviors.html +767 -0
- data/docs/DWH/Capabilities.html +748 -0
- data/docs/DWH/Column.html +1115 -0
- data/docs/DWH/ConfigError.html +143 -0
- data/docs/DWH/ConnectionError.html +143 -0
- data/docs/DWH/DWHError.html +138 -0
- data/docs/DWH/ExecutionError.html +143 -0
- data/docs/DWH/Factory.html +1133 -0
- data/docs/DWH/Functions/Arrays.html +505 -0
- data/docs/DWH/Functions/Dates.html +1644 -0
- data/docs/DWH/Functions/ExtractDatePart.html +804 -0
- data/docs/DWH/Functions/Nulls.html +377 -0
- data/docs/DWH/Functions.html +846 -0
- data/docs/DWH/Logger.html +258 -0
- data/docs/DWH/OAuthError.html +138 -0
- data/docs/DWH/Settings.html +658 -0
- data/docs/DWH/StreamingStats.html +804 -0
- data/docs/DWH/Table.html +1260 -0
- data/docs/DWH/TableStats.html +583 -0
- data/docs/DWH/TokenExpiredError.html +142 -0
- data/docs/DWH/UnsupportedCapability.html +135 -0
- data/docs/DWH.html +220 -0
- data/docs/_index.html +471 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/file.README.html +210 -0
- data/docs/file.adapters.html +514 -0
- data/docs/file.creating-adapters.html +497 -0
- data/docs/file.getting-started.html +288 -0
- data/docs/file.usage.html +446 -0
- data/docs/file_list.html +79 -0
- data/docs/frames.html +22 -0
- data/docs/guides/adapters.md +445 -0
- data/docs/guides/creating-adapters.md +430 -0
- data/docs/guides/getting-started.md +225 -0
- data/docs/guides/usage.md +378 -0
- data/docs/index.html +210 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +2038 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/dwh/adapters/athena.rb +359 -0
- data/lib/dwh/adapters/druid.rb +267 -0
- data/lib/dwh/adapters/duck_db.rb +235 -0
- data/lib/dwh/adapters/my_sql.rb +235 -0
- data/lib/dwh/adapters/open_authorizable.rb +215 -0
- data/lib/dwh/adapters/postgres.rb +250 -0
- data/lib/dwh/adapters/snowflake.rb +489 -0
- data/lib/dwh/adapters/sql_server.rb +257 -0
- data/lib/dwh/adapters/trino.rb +213 -0
- data/lib/dwh/adapters.rb +363 -0
- data/lib/dwh/behaviors.rb +67 -0
- data/lib/dwh/capabilities.rb +39 -0
- data/lib/dwh/column.rb +79 -0
- data/lib/dwh/errors.rb +29 -0
- data/lib/dwh/factory.rb +125 -0
- data/lib/dwh/functions/arrays.rb +42 -0
- data/lib/dwh/functions/dates.rb +162 -0
- data/lib/dwh/functions/extract_date_part.rb +70 -0
- data/lib/dwh/functions/nulls.rb +31 -0
- data/lib/dwh/functions.rb +86 -0
- data/lib/dwh/logger.rb +50 -0
- data/lib/dwh/settings/athena.yml +77 -0
- data/lib/dwh/settings/base.yml +81 -0
- data/lib/dwh/settings/databricks.yml +51 -0
- data/lib/dwh/settings/druid.yml +59 -0
- data/lib/dwh/settings/duckdb.yml +44 -0
- data/lib/dwh/settings/mysql.yml +67 -0
- data/lib/dwh/settings/postgres.yml +30 -0
- data/lib/dwh/settings/redshift.yml +52 -0
- data/lib/dwh/settings/snowflake.yml +45 -0
- data/lib/dwh/settings/sqlserver.yml +80 -0
- data/lib/dwh/settings/trino.yml +77 -0
- data/lib/dwh/settings.rb +79 -0
- data/lib/dwh/streaming_stats.rb +69 -0
- data/lib/dwh/table.rb +105 -0
- data/lib/dwh/table_stats.rb +51 -0
- data/lib/dwh/version.rb +5 -0
- data/lib/dwh.rb +54 -0
- data/sig/dwh.rbs +4 -0
- metadata +231 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3971b0c0d4f6964a2f6d1ce8d04038f3f79e09036cd8ab19a2c5dd866d5411ca
|
4
|
+
data.tar.gz: 567185f3ec75fa9b606538031076f8215e376257a421159f6139dfc951e43e30
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75c38e6b03b9d6759cc43d363924b6cbffa91bfd2af30e327d864371c5c77143071d909f8b805d44fb59de679ad23ed1be0294a99906ef435b5effb18a381e33
|
7
|
+
data.tar.gz: e8e5ac7103954e9c644a0fbfc819b66ef673bbd4a85dd9a8a96a6b4cacb86dd50b73e37aeb1cba4bd049a190d42a3f78f7024235b8b0c4fd4c44a0f931f581fb
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Layout/LineLength:
|
2
|
+
Max: 150
|
3
|
+
|
4
|
+
Metrics/MethodLength:
|
5
|
+
Max: 50
|
6
|
+
|
7
|
+
Metrics/AbcSize:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Style/FrozenStringLiteralComment:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/ClassLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/ModuleLength:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/CyclomaticComplexity:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/ParameterLists:
|
23
|
+
Max: 10
|
24
|
+
|
25
|
+
Lint/UnusedMethodArgument:
|
26
|
+
Exclude:
|
27
|
+
- 'lib/dwh/adapters/**/*.rb'
|
28
|
+
|
29
|
+
Metrics/PerceivedComplexity:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/SymbolProc:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Metrics/BlockLength:
|
36
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Strata Business Intelligence
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
|
2
|
+
[](https://github.com/stratasite/dwh/actions)
|
3
|
+
|
4
|
+
# DWH - Data Warehouse Adapter Library
|
5
|
+
|
6
|
+
A light weight library to connect, introspect, and query popular databases over a unified interface. This gem is intended for analtyical workloads. The library also provides database specific translations for common functions like `date_trunc`, `date_add` etc. The function tranlation is not comprehensive. But, it does provides good coverage for date handling, and some array handling as well.
|
7
|
+
|
8
|
+
> [!NOTE]
|
9
|
+
> **This is not an ORM** nor will it cast types to ruby unless the underlying client does it out of the box. The goal here is to create an Architecture where new databases can be onboarded quickly.
|
10
|
+
|
11
|
+
## Why do we need another database abstraction layer?
|
12
|
+
|
13
|
+
Libraries like [Sequel](https://github.com/jeremyevans/sequel) are amazing and comprehensive. However, its broad coverage also makes it more laborious to add new databases. Especially, ones with only HTTP endpoints for Ruby. We seem to be having an explosion of databases recently and a light weight interface will allow us to integrate faster.
|
14
|
+
|
15
|
+
The adapter only has 5 core methods (6 including the connection method). A YAML settings controls how it interacts with a particular db. It is relatively fast to add a new db. See the [Druid](http://github.com/stratasite/dwh/blob/main/lib/dwh/adapters/druid.rb) implementation as an example. And [here](https://github.com/stratasite/dwh/blob/main/lib/dwh/settings/druid.yml) is its corresponding YAML settings file.
|
16
|
+
|
17
|
+
## Features
|
18
|
+
|
19
|
+
- **Unified Interface**: Connect to multiple database types using the same API
|
20
|
+
- **SQL Function Translation**: Automatically translates common SQL functions to database-specific syntax
|
21
|
+
- **Connection Pooling**: Built-in connection pool management for high-performance applications
|
22
|
+
- **Rich Metadata**: Extract table schemas, column information, and statistics
|
23
|
+
|
24
|
+
## Supported Databases
|
25
|
+
|
26
|
+
- **Snowflake** - High performance cloud warehouse
|
27
|
+
- **Trino** (formerly Presto) - Distributed SQL query engine
|
28
|
+
- **AWS Athena** - AWS big data warehouse
|
29
|
+
- **Apache Druid** - Real-time analytics database
|
30
|
+
- **DuckDB** - In-process analytical database
|
31
|
+
- **PostgreSQL** - Full-featured RDBMS with advanced SQL support
|
32
|
+
- **MySQL** - Popular open-source database
|
33
|
+
- **SQL Server** - Microsoft's enterprise database
|
34
|
+
|
35
|
+
## Integrations Coming Soon
|
36
|
+
|
37
|
+
- **Redshift** - AWS data warehouse platform
|
38
|
+
- **ClickHouse** - High performance analytical db
|
39
|
+
- **Databricks** - Big data compute engine
|
40
|
+
- **MotherDuck** - Hosted DuckDB service
|
41
|
+
|
42
|
+
## Quick Start
|
43
|
+
|
44
|
+
Install it yourself as:
|
45
|
+
|
46
|
+
```bash
|
47
|
+
gem install dwh
|
48
|
+
```
|
49
|
+
|
50
|
+
### Connect and Execute a Basic Query
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
require 'dwh'
|
54
|
+
|
55
|
+
# Connect to Druid
|
56
|
+
druid = DWH.create(:druid, {
|
57
|
+
host: 'localhost',
|
58
|
+
port: 8080,
|
59
|
+
protocol: 'http'
|
60
|
+
})
|
61
|
+
|
62
|
+
# basic query execution
|
63
|
+
results = druid.execute("SELECT * FROM web_sales", format: :csv)
|
64
|
+
```
|
65
|
+
|
66
|
+
## Core API
|
67
|
+
|
68
|
+
Standardized API across adapters:
|
69
|
+
|
70
|
+
<dl>
|
71
|
+
<dt>connection</dt>
|
72
|
+
<dd>Creates a reusuable connection based on config hash passed in</dd>
|
73
|
+
<dt>tables(schema: nil, catalog: nil)</dt>
|
74
|
+
<dd> returns a list of tables from the default connection or from the specified schema and catalog </dd>
|
75
|
+
<dt> metadata(table_name, schema: nil, catalog: nil) </dt>
|
76
|
+
<dd> provides metadata about a table </dd>
|
77
|
+
<dt>stats(table_name, date_column: nil) </dt>
|
78
|
+
<dd> provides table row count and date range </dd>
|
79
|
+
<dt> execute(sql, format: :array, retries: 0) </dt>
|
80
|
+
<dd> runs a query and returns in given format </dd>
|
81
|
+
<dt> execute_stream(sql, io, stats: nil) </dt>
|
82
|
+
<dd> runs a query and streams it as csv into the given io </dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
## Tutorials and Guides
|
86
|
+
|
87
|
+
- [Getting Started](/docs/guides/getting-started.md)
|
88
|
+
- [Adapter Configuration](/docs/guides/adapters.md)
|
89
|
+
- [Creating an Adapter](/docs/guides/creating-adapters.md)
|
90
|
+
- [API](https://rubydoc.info/github/stratasite/dwh.git)
|
91
|
+
|
92
|
+
## Testing
|
93
|
+
|
94
|
+
Certain databases have to be tested via docker. Those tests will try to launch docker compose services in `test/support/compose*.yml`
|
95
|
+
|
96
|
+
Run Unit Tests:
|
97
|
+
|
98
|
+
```bash
|
99
|
+
bundle exec rake test:unit
|
100
|
+
```
|
101
|
+
|
102
|
+
Run tests on RDBMS dbs:
|
103
|
+
|
104
|
+
```bash
|
105
|
+
bundle exec rake test:system:rdbms
|
106
|
+
```
|
107
|
+
|
108
|
+
Run tests on druid:
|
109
|
+
|
110
|
+
```bash
|
111
|
+
bundle exec rake test:system:druid
|
112
|
+
```
|
113
|
+
|
114
|
+
## Development
|
115
|
+
|
116
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt.
|
117
|
+
|
118
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
119
|
+
|
120
|
+
## Contributing
|
121
|
+
|
122
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/stratasite/dwh>.
|
123
|
+
|
124
|
+
## License
|
125
|
+
|
126
|
+
This project is available as open source under the terms of the MIT License.
|
127
|
+
|
128
|
+
## Version
|
129
|
+
|
130
|
+
Current version: 0.1.0
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'minitest/test_task'
|
5
|
+
require 'yard'
|
6
|
+
|
7
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
8
|
+
t.files = ['lib/**/*.rb']
|
9
|
+
|
10
|
+
# Output directory
|
11
|
+
t.options = [
|
12
|
+
'--output-dir', 'docs',
|
13
|
+
'--markup', 'markdown',
|
14
|
+
'--markup-provider', 'kramdown',
|
15
|
+
'--charset', 'utf-8',
|
16
|
+
'--verbose', '--debug',
|
17
|
+
'--files', 'docs/guides/*.md'
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
namespace :test do
|
22
|
+
Minitest::TestTask.create :unit do |t|
|
23
|
+
t.test_globs = ['test/unit/**/*_test.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :system do
|
27
|
+
Minitest::TestTask.create :rdbms do |t|
|
28
|
+
t.test_globs = ['test/system/rdbms_*_test.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
Minitest::TestTask.create :druid do |t|
|
32
|
+
t.test_globs = ['test/system/druid_test.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
Minitest::TestTask.create :cloud do |t|
|
36
|
+
t.test_globs = ['test/system/cloud_test.rb']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# task test: %i[test:unit]
|
42
|
+
# task test_all: %i[test:unit test:system:all]
|