class Sequel::Bigquery::Dataset
end
Public Instance Methods
fetch_rows(sql) { |row| ... }
click to toggle source
# File lib/sequel-bigquery.rb, line 202 def fetch_rows(sql) puts '#fetch_rows' # execute(sql) do |s| # i = -1 # cols = s.columns(true).map{|c| [output_identifier(c.name), c.type, i+=1]} # columns = cols.map{|c| c[0]} # self.columns = columns # s.each do |row| # hash = {} # cols.each{|n,t,j| hash[n] = convert_odbc_value(row[j], t)} # yield hash # end # end # self execute(sql) do |bq_result| self.columns = bq_result.fields.map { |field| field.name.to_sym } bq_result.each do |row| yield row end end # execute(sql).each do |row| # yield row # end self end
Private Instance Methods
literal_false()
click to toggle source
def literal_date(v)
v.strftime("{d '%Y-%m-%d'}")
end
# File lib/sequel-bigquery.rb, line 267 def literal_false 'false' end
literal_time(v)
click to toggle source
def convert_odbc_value(v, t)
# When fetching a result set, the Ruby ODBC driver converts all ODBC # SQL types to an equivalent Ruby type; with the exception of # SQL_TYPE_DATE, SQL_TYPE_TIME and SQL_TYPE_TIMESTAMP. # # The conversions below are consistent with the mappings in # ODBCColumn#mapSqlTypeToGenericType and Column#klass. case v when ::ODBC::TimeStamp db.to_application_timestamp([v.year, v.month, v.day, v.hour, v.minute, v.second, v.fraction]) when ::ODBC::Time Sequel::SQLTime.create(v.hour, v.minute, v.second) when ::ODBC::Date Date.new(v.year, v.month, v.day) else if t == ::ODBC::SQL_BIT v == 1 else v end end
end
# File lib/sequel-bigquery.rb, line 259 def literal_time(v) "'#{v.iso8601}'" end
literal_true()
click to toggle source
# File lib/sequel-bigquery.rb, line 271 def literal_true 'true' end