Module: Sequel::MakeReadyable
- Defined in:
- lib/sequel/extensions/make_readyable.rb
Instance Method Summary collapse
-
#make_ready(opts = {}) ⇒ Object
This method is primarily geared towards Spark SQL-based databases.
Instance Method Details
#make_ready(opts = {}) ⇒ Object
This method is primarily geared towards Spark SQL-based databases.
Given some options, prepares a set of views to represent a set of tables across a collection of different schemas and external, unmanaged tables.
DB.make_ready(use_schema: :schema)
# => USE `schema`
When using search_path, tables from previous schema override tables from the next schema. This is analogous to the way Unix searches the PATH variable for programs.
Assuming the following tables: schema1.a, schema2.a, schema2.b
DB.make_ready(search_path: [:schema1, :schema2])
# => CREATE TEMPORARY VIEW `a` AS SELECT * FROM `schema1`.`a;`
# => CREATE TEMPORARY VIEW `b` AS SELECT * FROM `schema2`.`b;`
When using Pathnames, the extension on the file becomes the format to try to read from the file.
DB.make_ready(search_path: [Pathname.new("c.parquet"), Pathname.new("d.orc")])
# => CREATE TEMPORARY VIEW `c` USING parquet OPTIONS ('path'='c.parquet')
# => CREATE TEMPORARY VIEW `d` USING orc OPTIONS ('path'='d.orc')
33 34 35 |
# File 'lib/sequel/extensions/make_readyable.rb', line 33 def make_ready(opts = {}) ReadyMaker.new(self, opts).run end |