Sha256: 5d331e935faccbaf68e01963ee9b817cee6819d3bb24bc5e8291667482c1908a
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
require "active_support" require "active_support/core_ext" require "bq_factory/version" require "bq_factory/attribute" require "bq_factory/record" require "bq_factory/client" require "bq_factory/configuration" require "bq_factory/errors" require "bq_factory/proxy" require "bq_factory/query_builder" require "bq_factory/table" require "bq_factory/record" require "bq_factory/registory" require "bq_factory/registory_decorator" module BqFactory class << self delegate :fetch_schema_from_bigquery, :create_dataset!, :delete_dataset!, :create_table!, :delete_table!, :query, :table_by_name, :configuration, :project_id, :keyfile_path, :client, to: :proxy def configure yield configuration if block_given? configuration end def create_view(dataset_name, factory_name, rows, view_name = nil) view_name ||= factory_name query = build_query(factory_name, rows) client.create_view(dataset_name, view_name, query) end 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 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 def registered?(name) name = name.to_sym proxy.registered?(name) end private def proxy @proxy ||= Proxy.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bq_factory-0.2.0 | lib/bq_factory.rb |