Module: ClickHouse::Extend::ConnectionExplaining

Included in:
Connection
Defined in:
lib/click_house/extend/connection_explaining.rb

Constant Summary collapse

EXPLAIN =
'EXPLAIN'
EXPLAIN_RE =
/\A(\s*#{EXPLAIN})/io.freeze

Instance Method Summary collapse

Instance Method Details

#explain(sql, io: StringIO.new) ⇒ Object

Returns String.

Returns:

  • String


10
11
12
13
14
# File 'lib/click_house/extend/connection_explaining.rb', line 10

def explain(sql, io: StringIO.new)
  res = execute("#{EXPLAIN} #{sql.gsub(EXPLAIN_RE, '')}")
  io.puts(res.body)
  io.string
end