Module: BqFactory
- Defined in:
- lib/bq_factory.rb,
lib/bq_factory/proxy.rb,
lib/bq_factory/table.rb,
lib/bq_factory/client.rb,
lib/bq_factory/errors.rb,
lib/bq_factory/record.rb,
lib/bq_factory/version.rb,
lib/bq_factory/attribute.rb,
lib/bq_factory/registory.rb,
lib/bq_factory/configuration.rb,
lib/bq_factory/query_builder.rb,
lib/bq_factory/registory_decorator.rb
Defined Under Namespace
Classes: Attribute, Client, Configuration, DuplicateDefinitionError, Proxy, QueryBuilder, Record, Registory, RegistoryDecorator, Table
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.build_query(register_name, rows) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/bq_factory.rb', line 31
def build_query(register_name, rows)
table = table_by_name(register_name)
schema = table.schema
if schema.nil?
schema = proxy.fetch_schema_from_bigquery(table.dataset, table.name)
table.schema = schema
end
QueryBuilder.new(schema).build(rows)
end
|
21
22
23
24
|
# File 'lib/bq_factory.rb', line 21
def configure
yield configuration if block_given?
configuration
end
|
.create_view(dataset_name, factory_name, rows) ⇒ Object
26
27
28
29
|
# File 'lib/bq_factory.rb', line 26
def create_view(dataset_name, factory_name, rows)
query = build_query(factory_name, rows)
client.create_view(dataset_name, factory_name, query)
end
|
.register(name, dataset:, table: nil, schema: nil) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/bq_factory.rb', line 43
def register(name, dataset:, table: nil, schema: nil)
name = name.to_sym
table_name = table.nil? ? name : table
proxy.register(name, Table.new(table_name, dataset, schema))
end
|