Class: Sequel::ReadyMaker::FileSourcerer
- Inherits:
-
Object
- Object
- Sequel::ReadyMaker::FileSourcerer
- Defined in:
- lib/sequel/extensions/make_readyable.rb
Overview
FileSourcerer
Handles external file sources for the make_ready functionality. This class creates temporary views that read from external files like Parquet, ORC, etc.
Instance Attribute Summary collapse
-
#db ⇒ Sequel::Database
readonly
The database instance.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
-
#create_view(table, opts = {}) ⇒ Object
Creates a temporary view that reads from the external file.
-
#initialize(db, schema) ⇒ FileSourcerer
constructor
Creates a new FileSourcerer instance.
-
#tables(_opts = {}) ⇒ Array<Symbol>
Returns the table name derived from the file name.
Constructor Details
#initialize(db, schema) ⇒ FileSourcerer
Creates a new FileSourcerer instance.
150 151 152 153 |
# File 'lib/sequel/extensions/make_readyable.rb', line 150 def initialize(db, schema) @db = db @schema = schema end |
Instance Attribute Details
#db ⇒ Sequel::Database (readonly)
Returns the database instance.
144 145 146 |
# File 'lib/sequel/extensions/make_readyable.rb', line 144 def db @db end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
144 |
# File 'lib/sequel/extensions/make_readyable.rb', line 144 attr_reader :db, :schema |
Instance Method Details
#create_view(table, opts = {}) ⇒ Object
Creates a temporary view that reads from the external file.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/sequel/extensions/make_readyable.rb', line 167 def create_view(table, opts = {}) case db.database_type when :spark # Spark SQL uses USING clause for external tables db.create_view(table, { temp: true, using: format, options: { path: schema. }, }.merge(opts)) when :duckdb # DuckDB uses direct file reading with read_* functions create_duckdb_view(table, opts) else raise Sequel::Error, "External file sources are not supported on #{db.database_type}" end end |
#tables(_opts = {}) ⇒ Array<Symbol>
Returns the table name derived from the file name.
159 160 161 |
# File 'lib/sequel/extensions/make_readyable.rb', line 159 def tables(_opts = {}) [schema.basename(schema.extname).to_s.to_sym] end |