Module: Sequel::Snowflake::DatasetMethods
- Included in:
- Dataset
- Defined in:
- lib/sequel/adapters/shared/snowflake.rb
Instance Method Summary collapse
-
#explain(opts = OPTS) ⇒ Object
Return an array of strings specifying a query explanation for a SELECT of the current dataset.
Instance Method Details
#explain(opts = OPTS) ⇒ Object
Return an array of strings specifying a query explanation for a SELECT of the current dataset. The options (symbolized, in lowercase) are:
JSON: JSON output is easier to store in a table and query.
TABULAR (default): tabular output is generally more human-readable than JSON output.
TEXT: formatted text output is generally more human-readable than JSON output.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sequel/adapters/shared/snowflake.rb', line 12 def explain(opts=OPTS) # Load the PrettyTable class, needed for explain output Sequel.extension(:_pretty_table) unless defined?(Sequel::PrettyTable) explain_with_format = if opts[:tabular] "EXPLAIN USING TABULAR" elsif opts[:json] "EXPLAIN USING JSON" elsif opts[:text] "EXPLAIN USING TEXT" else "EXPLAIN" end ds = db.send(:metadata_dataset).clone(:sql=>"#{explain_with_format} #{select_sql}") rows = ds.all Sequel::PrettyTable.string(rows, ds.columns) end |