sequel-bigquery 0.4.2 → 0.5.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 +4 -4
- data/README.md +27 -4
- data/lib/sequel-bigquery.rb +7 -0
- data/lib/sequel_bigquery/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c37139c40fd486391d9d16ab147430352b67a1a2b5a55f7eed4189c368b5e87a
|
4
|
+
data.tar.gz: e3753842a9727cf53451ff80ac9abc250343a719d4215ab368c5a93a9d2b4830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6189f0b53a6edd9d66c915316ce8e9e8c836181609405b54e246c0dbe5451bce995c6f5b73e7b320624c35b62bfd66874757734f839ef7f9023dbc099271b2a4
|
7
|
+
data.tar.gz: 715b5adbdb6e225ca9af37363fbc30b59bde54a0b4602d91afcca93506cac541d252b31767571605ee555f2fdaad8d316ccf67a083354bfdcc9cd5f925c51646
|
data/README.md
CHANGED
@@ -13,6 +13,11 @@ Beyond migrations, I'm unsure how useful this gem is. I haven't yet tested what
|
|
13
13
|
<!-- MarkdownTOC autolink=true -->
|
14
14
|
|
15
15
|
- [Intro](#intro)
|
16
|
+
- [Quirks](#quirks)
|
17
|
+
- [Creating tables with column defaults](#creating-tables-with-column-defaults)
|
18
|
+
- [Transactions](#transactions)
|
19
|
+
- [Update statements without `WHERE`](#update-statements-without-where)
|
20
|
+
- [Alter table](#alter-table)
|
16
21
|
- [Installation](#installation)
|
17
22
|
- [Usage](#usage)
|
18
23
|
- [Contributing](#contributing)
|
@@ -29,12 +34,12 @@ Beyond migrations, I'm unsure how useful this gem is. I haven't yet tested what
|
|
29
34
|
Features:
|
30
35
|
|
31
36
|
- Connecting
|
32
|
-
- Migrating
|
33
|
-
- Table creation
|
37
|
+
- Migrating (see quirks)
|
38
|
+
- Table creation (see quirks)
|
34
39
|
- Inserting rows
|
35
|
-
- Updating rows
|
40
|
+
- Updating rows (see quirks)
|
36
41
|
- Querying
|
37
|
-
- Transactions (
|
42
|
+
- Transactions (see quirks)
|
38
43
|
- Table partitioning
|
39
44
|
- Ruby types:
|
40
45
|
+ String
|
@@ -46,6 +51,24 @@ Features:
|
|
46
51
|
+ BigDecimal
|
47
52
|
- Selecting the BigQuery server location
|
48
53
|
|
54
|
+
## Quirks
|
55
|
+
|
56
|
+
### Creating tables with column defaults
|
57
|
+
|
58
|
+
BigQuery doesn't support defaults on columns. As a workaround, all defaults are automatically removed from statements (crudely).
|
59
|
+
|
60
|
+
### Transactions
|
61
|
+
|
62
|
+
BigQuery doesn't support transactions where the statements are executed individually. It does support them if entire transaction SQL is sent all at once though. As a workaround, buffering of statements within a transaction has been implemented. However, the impact of this is that no results can be returned within a transaction.
|
63
|
+
|
64
|
+
### Update statements without `WHERE`
|
65
|
+
|
66
|
+
BigQuery requires all `UPDATE` statement to have a `WHERE` clause. As a workaround, statements which lack one have `where 1 = 1` appended automatically (crudely).
|
67
|
+
|
68
|
+
### Alter table
|
69
|
+
|
70
|
+
We've found that the `google-cloud-bigquery` gem seems to have a bug where an internal lack of result value results in a `NoMethodError` on nil for `fields` within `from_gapi_json`. [See issue #6](https://github.com/ZimbiX/sequel-bigquery/issues/6#issuecomment-968523731). As a workaround, all generated statements within `alter_table` are joined together with `;` and executed only at the end of the block. A `select 1` is also appended to try to ensure we have a result to avoid the aforementioned exception. A bonus of batching the queries is that the latency should be somewhat reduced.
|
71
|
+
|
49
72
|
## Installation
|
50
73
|
|
51
74
|
Add it to the `Gemfile` of your project:
|
data/lib/sequel-bigquery.rb
CHANGED
@@ -209,6 +209,13 @@ module Sequel
|
|
209
209
|
|
210
210
|
sql
|
211
211
|
end
|
212
|
+
|
213
|
+
# Batch the alter table queries and make sure something is returned to avoid an error related to the return value
|
214
|
+
def apply_alter_table(name, ops)
|
215
|
+
sqls = alter_table_sql_list(name, ops)
|
216
|
+
sqls_joined = (sqls + ['select 1']).join(";\n")
|
217
|
+
execute_ddl(sqls_joined)
|
218
|
+
end
|
212
219
|
end
|
213
220
|
|
214
221
|
class Dataset < Sequel::Dataset
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-bigquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendan Weibrecht
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|