Class: Turboquery::OLAP
Defined Under Namespace
Classes: AROLAP
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Connection
#after_fork, #config, #dump_table_ddl, #execute, #set_env, #table_exists?
Class Method Details
.after_fork ⇒ Object
29
30
31
|
# File 'lib/turboquery/olap.rb', line 29
def self.after_fork
AROLAP.connect
end
|
Instance Method Details
#copy_result_to_s3(query) ⇒ Object
6
7
8
9
10
|
# File 'lib/turboquery/olap.rb', line 6
def copy_result_to_s3(query)
key = random_key
execute("UNLOAD ('#{query}') TO 's3://#{Turboquery.aws_bucket}/#{key}' #{copy_options};")
key
end
|
#copy_s3_to_table(key, table) ⇒ Object
12
13
14
15
|
# File 'lib/turboquery/olap.rb', line 12
def copy_s3_to_table(key, table)
execute("COPY #{table} FROM 's3://#{Turboquery.aws_bucket}/#{key}manifest' #{copy_options}
DATEFORMAT 'auto' TIMEFORMAT 'auto';")
end
|
#copy_table_to_s3(table) ⇒ Object
2
3
4
|
# File 'lib/turboquery/olap.rb', line 2
def copy_table_to_s3(table)
copy_result_to_s3("SELECT * FROM #{table}")
end
|
#drop_table(key) ⇒ Object
24
25
26
27
|
# File 'lib/turboquery/olap.rb', line 24
def drop_table(key)
sql = "DROP TABLE IF EXISTS #{key}"
execute(sql)
end
|
#execute_to_temporary_table(query) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/turboquery/olap.rb', line 17
def execute_to_temporary_table(query)
key = random_key
sql = "CREATE TEMPORARY TABLE #{key} AS #{query}"
execute(sql)
key
end
|