Class: Blazer::Adapters::BigQueryAdapter
Instance Attribute Summary
Attributes inherited from BaseAdapter
#data_source
Instance Method Summary
collapse
Methods inherited from BaseAdapter
#cachable?, #cancel, #cohort_analysis_statement, #cost, #explain, #initialize, #reconnect, #supports_cohort_analysis?
Instance Method Details
#parameter_binding ⇒ Object
52
53
54
|
# File 'lib/blazer/adapters/bigquery_adapter.rb', line 52
def parameter_binding
:positional
end
|
#preview_statement ⇒ Object
42
43
44
|
# File 'lib/blazer/adapters/bigquery_adapter.rb', line 42
def preview_statement
"SELECT * FROM `{table}` LIMIT 10"
end
|
#quoting ⇒ Object
47
48
49
|
# File 'lib/blazer/adapters/bigquery_adapter.rb', line 47
def quoting
:backslash_escape
end
|
#run_statement(statement, comment, bind_params) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/blazer/adapters/bigquery_adapter.rb', line 4
def run_statement(statement, , bind_params)
columns = []
rows = []
error = nil
begin
results = bigquery.query(statement, params: bind_params)
if !results.respond_to?(:complete?) || results.complete?
columns = results.first.keys.map(&:to_s) if results.size > 0
rows = results.all.map(&:values)
else
error = Blazer::TIMEOUT_MESSAGE
end
rescue => e
error = e.message
error = Blazer::VARIABLE_MESSAGE if error.include?("Syntax error: Unexpected \"?\"")
end
[columns, rows, error]
end
|
#schema ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/blazer/adapters/bigquery_adapter.rb', line 32
def schema
table_refs.map do |table_ref|
{
schema: table_ref.dataset_id,
table: table_ref.table_id,
columns: table_columns(table_ref)
}
end
end
|
#tables ⇒ Object
28
29
30
|
# File 'lib/blazer/adapters/bigquery_adapter.rb', line 28
def tables
table_refs.map { |t| "#{t.project_id}.#{t.dataset_id}.#{t.table_id}" }
end
|