Method: Clickhouse::Connection::Query#to_select_query

Defined in:
lib/clickhouse/connection/query.rb

#to_select_query(options) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/clickhouse/connection/query.rb', line 77

def to_select_query(options)
  to_select_options(options).collect do |(key, value)|
    next if value.nil? || (value.respond_to?(:empty?) && value.empty?)

    statement = [key.to_s.upcase]
    statement << "BY" if %W(GROUP ORDER).include?(statement[0])
    statement << to_segment(key, value)
    statement.join(" ")

  end.compact.join("\n").force_encoding("UTF-8")
end