-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup_regress
executable file
·52 lines (42 loc) · 1.17 KB
/
setup_regress
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
require 'erb'
require 'optparse'
class Converter
def initialize(apikey, query_engine, pg_role)
@apikey = apikey
@query_engine = query_engine
@pg_role = pg_role
end
def convert(temp_path, out_path)
temp = File.read(temp_path)
File.write(out_path, ERB.new(temp).result(binding))
end
end
if __FILE__ == $0
options = {:role => 'postgres'}
op = OptionParser.new do |opts|
opts.banner = "Usage: TD_TEST_APIKEY=your_td_test_apikey #{$0} query_engine [options]"
opts.on("-r", "--role ROLE", "Role in PostgreSQL") do |v|
options[:role] = v
end
end
op.parse!
unless ARGV.size >= 1
puts op
exit 1
end
query_engine = ARGV.shift
unless apikey = ENV['TD_TEST_APIKEY']
puts "Environment variable TD_TEST_APIKEY isn't set"
puts op
exit 1
end
unless %w|hive presto|.include?(query_engine)
puts "query_engine should be either 'hive' or 'presto'"
puts op
exit 1
end
conv = Converter.new(apikey, query_engine, options[:role])
conv.convert('sql/treasuredata_fdw.sql.erb', 'sql/treasuredata_fdw.sql')
conv.convert('expected/treasuredata_fdw.out.erb', 'expected/treasuredata_fdw.out')
end