mondrian-olap 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +21 -1
- data/README.md +4 -4
- data/VERSION +1 -1
- data/lib/mondrian/jars/log4j-api-2.17.1.jar +0 -0
- data/lib/mondrian/jars/log4j-core-2.17.1.jar +0 -0
- data/lib/mondrian/jars/log4j2-config.jar +0 -0
- data/lib/mondrian/jars/mondrian-9.3.0.0.jar +0 -0
- data/lib/mondrian/olap/connection.rb +33 -20
- data/lib/mondrian/olap/cube.rb +46 -4
- data/lib/mondrian/olap/error.rb +10 -2
- data/lib/mondrian/olap/query.rb +1 -0
- data/lib/mondrian/olap/result.rb +128 -59
- data/lib/mondrian/olap/schema.rb +9 -3
- data/lib/mondrian/olap/schema_udf.rb +8 -82
- data/lib/mondrian/olap.rb +11 -7
- data/spec/connection_spec.rb +37 -3
- data/spec/cube_cache_control_spec.rb +2 -2
- data/spec/cube_spec.rb +36 -2
- data/spec/fixtures/MondrianTest.xml +40 -0
- data/spec/fixtures/MondrianTestOracle.xml +40 -0
- data/spec/mondrian_spec.rb +132 -0
- data/spec/query_spec.rb +86 -21
- data/spec/rake_tasks.rb +85 -16
- data/spec/schema_definition_spec.rb +0 -235
- data/spec/spec_helper.rb +317 -75
- data/spec/support/data/customers.csv +111 -111
- data/spec/support/data/promotions.csv +11 -0
- data/spec/support/data/sales.csv +101 -101
- data/spec/support/data/warehouse.csv +101 -0
- data/spec/support/matchers/be_like.rb +1 -0
- metadata +36 -73
- data/lib/mondrian/jars/log4j-1.2.17.jar +0 -0
- data/lib/mondrian/jars/log4j.properties +0 -3
- data/lib/mondrian/jars/mondrian-9.1.0.0.jar +0 -0
data/spec/spec_helper.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
require 'rdoc'
|
2
2
|
require 'rspec'
|
3
3
|
require 'active_record'
|
4
|
-
# Patched adapter_java.jar with MySQL 8 JDBC driver support
|
5
|
-
require_relative 'support/jars/adapter_java.jar'
|
6
4
|
require 'activerecord-jdbc-adapter'
|
7
|
-
require 'coffee-script'
|
8
|
-
require 'rhino'
|
9
5
|
require 'pry'
|
10
6
|
|
11
|
-
#
|
7
|
+
# Autoload corresponding JDBC driver during require 'jdbc/...'
|
12
8
|
Java::JavaLang::System.setProperty("jdbc.driver.autoload", "true")
|
13
9
|
|
14
10
|
MONDRIAN_DRIVER = ENV['MONDRIAN_DRIVER'] || 'mysql'
|
15
11
|
env_prefix = MONDRIAN_DRIVER.upcase
|
16
12
|
|
17
13
|
DATABASE_HOST = ENV["#{env_prefix}_DATABASE_HOST"] || ENV['DATABASE_HOST'] || 'localhost'
|
14
|
+
DATABASE_PORT = ENV["#{env_prefix}_DATABASE_PORT"] || ENV['DATABASE_PORT']
|
15
|
+
DATABASE_PROTOCOL = ENV["#{env_prefix}_DATABASE_PROTOCOL"] || ENV['DATABASE_PROTOCOL']
|
18
16
|
DATABASE_USER = ENV["#{env_prefix}_DATABASE_USER"] || ENV['DATABASE_USER'] || 'mondrian_test'
|
19
17
|
DATABASE_PASSWORD = ENV["#{env_prefix}_DATABASE_PASSWORD"] || ENV['DATABASE_PASSWORD'] || 'mondrian_test'
|
20
18
|
DATABASE_NAME = ENV["#{env_prefix}_DATABASE_NAME"] || ENV['DATABASE_NAME'] || 'mondrian_test'
|
@@ -22,37 +20,130 @@ DATABASE_INSTANCE = ENV["#{env_prefix}_DATABASE_INSTANCE"] || ENV['DATABASE_INST
|
|
22
20
|
|
23
21
|
case MONDRIAN_DRIVER
|
24
22
|
when 'mysql', 'jdbc_mysql'
|
25
|
-
|
23
|
+
if jdbc_driver_file = Dir[File.expand_path("mysql*.jar", 'spec/support/jars')].first
|
24
|
+
require jdbc_driver_file
|
25
|
+
else
|
26
|
+
require 'jdbc/mysql'
|
27
|
+
end
|
26
28
|
JDBC_DRIVER = (Java::com.mysql.cj.jdbc.Driver rescue nil) ? 'com.mysql.cj.jdbc.Driver' : 'com.mysql.jdbc.Driver'
|
29
|
+
|
27
30
|
when 'postgresql'
|
28
31
|
require 'jdbc/postgres'
|
29
32
|
JDBC_DRIVER = 'org.postgresql.Driver'
|
33
|
+
require 'arjdbc/postgresql'
|
34
|
+
|
30
35
|
when 'oracle'
|
36
|
+
Dir[File.expand_path("ojdbc*.jar", 'spec/support/jars')].each do |jdbc_driver_file|
|
37
|
+
require jdbc_driver_file
|
38
|
+
end
|
31
39
|
require 'active_record/connection_adapters/oracle_enhanced_adapter'
|
40
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
|
41
|
+
# Start primary key sequences from 1 (and not 10000) and take just one next value in each session
|
42
|
+
self.default_sequence_start_value = "1 NOCACHE INCREMENT BY 1"
|
43
|
+
# PATCH: Restore previous mapping of ActiveRecord datetime to DATE type.
|
44
|
+
def supports_datetime_with_precision?; false; end
|
45
|
+
# PATCH: Do not send fractional seconds to DATE type.
|
46
|
+
def quoted_date(value)
|
47
|
+
if value.acts_like?(:time)
|
48
|
+
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
|
49
|
+
if value.respond_to?(zone_conversion_method)
|
50
|
+
value = value.send(zone_conversion_method)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
value.to_s(:db)
|
54
|
+
end
|
55
|
+
private
|
56
|
+
# PATCH: Restore previous mapping of ActiveRecord datetime to DATE type.
|
57
|
+
const_get(:NATIVE_DATABASE_TYPES)[:datetime] = {name: "DATE"}
|
58
|
+
alias_method :original_initialize_type_map, :initialize_type_map
|
59
|
+
def initialize_type_map(m = type_map)
|
60
|
+
original_initialize_type_map(m)
|
61
|
+
# PATCH: Map Oracle DATE to DateTime for backwards compatibility
|
62
|
+
register_class_with_precision m, %r(date)i, ActiveRecord::Type::DateTime
|
63
|
+
end
|
64
|
+
end
|
32
65
|
CATALOG_FILE = File.expand_path('../fixtures/MondrianTestOracle.xml', __FILE__)
|
33
|
-
|
34
|
-
require 'jdbc/jtds'
|
35
|
-
JDBC_DRIVER = 'net.sourceforge.jtds.jdbc.Driver'
|
66
|
+
|
36
67
|
when 'sqlserver'
|
37
|
-
Dir[File.expand_path("
|
68
|
+
Dir[File.expand_path("mssql-jdbc*.jar", 'spec/support/jars')].each do |jdbc_driver_file|
|
38
69
|
require jdbc_driver_file
|
39
70
|
end
|
71
|
+
require 'arjdbc/jdbc/adapter'
|
72
|
+
ActiveRecord::ConnectionAdapters::JdbcAdapter.class_eval do
|
73
|
+
def initialize(connection, logger = nil, connection_parameters = nil, config = {})
|
74
|
+
super(connection, logger, config.dup)
|
75
|
+
end
|
76
|
+
def modify_types(types)
|
77
|
+
types.merge!(
|
78
|
+
primary_key: 'bigint NOT NULL IDENTITY(1,1) PRIMARY KEY',
|
79
|
+
integer: {name: 'int'},
|
80
|
+
bigint: {name: 'bigint'},
|
81
|
+
boolean: {name: 'bit'},
|
82
|
+
decimal: {name: 'decimal'},
|
83
|
+
date: {name: 'date'},
|
84
|
+
datetime: {name: 'datetime'},
|
85
|
+
timestamp: {name: 'datetime'},
|
86
|
+
string: {name: 'nvarchar', limit: 4000},
|
87
|
+
text: {name: 'nvarchar(max)'}
|
88
|
+
)
|
89
|
+
end
|
90
|
+
def quote_table_name(name)
|
91
|
+
name.to_s.split('.').map { |n| quote_column_name(n) }.join('.')
|
92
|
+
end
|
93
|
+
def quote_column_name(name)
|
94
|
+
"[#{name.to_s}]"
|
95
|
+
end
|
96
|
+
def columns(table_name, name = nil)
|
97
|
+
select_all(
|
98
|
+
"SELECT * FROM information_schema.columns WHERE table_name = #{quote table_name}"
|
99
|
+
).map do |column|
|
100
|
+
ActiveRecord::ConnectionAdapters::Column.new(
|
101
|
+
column['COLUMN_NAME'],
|
102
|
+
column['COLUMN_DEFAULT'],
|
103
|
+
fetch_type_metadata(column['DATA_TYPE']),
|
104
|
+
column['IS_NULLABLE']
|
105
|
+
)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
def write_query?(sql)
|
109
|
+
sql =~ /\A(INSERT|UPDATE|DELETE) /
|
110
|
+
end
|
111
|
+
end
|
112
|
+
::Arel::Visitors::ToSql.class_eval do
|
113
|
+
private
|
114
|
+
def visit_Arel_Nodes_Limit(o, collector)
|
115
|
+
# Do not add LIMIT as it is not supported by MS SQL Server
|
116
|
+
collector
|
117
|
+
end
|
118
|
+
end
|
119
|
+
require "active_model/type/integer"
|
120
|
+
ActiveModel::Type::Integer::DEFAULT_LIMIT = 8
|
40
121
|
JDBC_DRIVER = 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
|
122
|
+
|
41
123
|
when 'vertica'
|
42
124
|
Dir[File.expand_path("vertica*.jar", 'spec/support/jars')].each do |jdbc_driver_file|
|
43
125
|
require jdbc_driver_file
|
44
126
|
end
|
45
127
|
JDBC_DRIVER = 'com.vertica.jdbc.Driver'
|
46
128
|
DATABASE_SCHEMA = ENV["#{env_prefix}_DATABASE_SCHEMA"] || ENV['DATABASE_SCHEMA'] || 'mondrian_test'
|
47
|
-
# patches for Vertica minimal AR support
|
48
129
|
require 'arjdbc/jdbc/adapter'
|
49
130
|
ActiveRecord::ConnectionAdapters::JdbcAdapter.class_eval do
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
131
|
+
def initialize(connection, logger = nil, connection_parameters = nil, config = {})
|
132
|
+
super(connection, logger, config.dup)
|
133
|
+
end
|
134
|
+
def modify_types(types)
|
135
|
+
types[:primary_key] = "int" # Use int instead of identity as data cannot be loaded into identity columns
|
136
|
+
types[:integer] = "int"
|
54
137
|
end
|
55
|
-
|
138
|
+
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
|
139
|
+
case type.to_sym
|
140
|
+
when :integer, :primary_key
|
141
|
+
'int' # All integers are 64-bit in Vertica and limit should be ignored
|
142
|
+
else
|
143
|
+
super
|
144
|
+
end
|
145
|
+
end
|
146
|
+
# By default Vertica stores table and column names in uppercase
|
56
147
|
def quote_table_name(name)
|
57
148
|
"\"#{name.to_s}\""
|
58
149
|
end
|
@@ -64,6 +155,7 @@ when 'vertica'
|
|
64
155
|
exec_update(sql, name, binds)
|
65
156
|
end
|
66
157
|
end
|
158
|
+
|
67
159
|
when 'snowflake'
|
68
160
|
Dir[File.expand_path("snowflake*.jar", 'spec/support/jars')].each do |jdbc_driver_file|
|
69
161
|
require jdbc_driver_file
|
@@ -74,10 +166,12 @@ when 'snowflake'
|
|
74
166
|
CATALOG_FILE = File.expand_path('../fixtures/MondrianTestOracle.xml', __FILE__)
|
75
167
|
require 'arjdbc/jdbc/adapter'
|
76
168
|
ActiveRecord::ConnectionAdapters::JdbcAdapter.class_eval do
|
77
|
-
def
|
78
|
-
|
79
|
-
|
80
|
-
|
169
|
+
def initialize(connection, logger = nil, connection_parameters = nil, config = {})
|
170
|
+
super(connection, logger, config.dup)
|
171
|
+
end
|
172
|
+
def modify_types(types)
|
173
|
+
types[:primary_key] = 'integer'
|
174
|
+
types[:integer] = 'integer'
|
81
175
|
end
|
82
176
|
# exec_insert tries to use Statement.RETURN_GENERATED_KEYS which is not supported by Snowflake
|
83
177
|
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
|
@@ -88,37 +182,171 @@ when 'snowflake'
|
|
88
182
|
# Hack to disable :text and :binary types for Snowflake
|
89
183
|
ActiveRecord::ConnectionAdapters::JdbcTypeConverter::AR_TO_JDBC_TYPES.delete(:text)
|
90
184
|
ActiveRecord::ConnectionAdapters::JdbcTypeConverter::AR_TO_JDBC_TYPES.delete(:binary)
|
185
|
+
|
186
|
+
when 'clickhouse'
|
187
|
+
Dir[File.expand_path("clickhouse*.jar", 'spec/support/jars')].each do |jdbc_driver_file|
|
188
|
+
require jdbc_driver_file
|
189
|
+
end
|
190
|
+
JDBC_DRIVER = 'com.clickhouse.jdbc.ClickHouseDriver'
|
191
|
+
DATABASE_SCHEMA = ENV["#{env_prefix}_DATABASE_SCHEMA"] || ENV['DATABASE_SCHEMA'] || 'mondrian_test'
|
192
|
+
require 'arjdbc/jdbc/adapter'
|
193
|
+
ActiveRecord::ConnectionAdapters::JdbcAdapter.class_eval do
|
194
|
+
def initialize(connection, logger = nil, connection_parameters = nil, config = {})
|
195
|
+
super(connection, logger, config.dup)
|
196
|
+
end
|
197
|
+
NATIVE_DATABASE_TYPES = {
|
198
|
+
primary_key: "Int32", # We do not need automatic primary key generation and need to allow inserting PK values
|
199
|
+
string: {name: "String"},
|
200
|
+
text: {name: "String"},
|
201
|
+
integer: {name: "Int32"},
|
202
|
+
float: {name: "Float64"},
|
203
|
+
numeric: {name: "Decimal"},
|
204
|
+
decimal: {name: "Decimal"},
|
205
|
+
datetime: {name: "DateTime"},
|
206
|
+
timestamp: {name: "DateTime"},
|
207
|
+
time: {name: "DateTime"},
|
208
|
+
date: {name: "Date"},
|
209
|
+
binary: {name: "String"},
|
210
|
+
boolean: {name: "Boolean"},
|
211
|
+
}
|
212
|
+
def native_database_types
|
213
|
+
NATIVE_DATABASE_TYPES
|
214
|
+
end
|
215
|
+
def modify_types(types)
|
216
|
+
types[:primary_key] = 'Int32'
|
217
|
+
types[:integer] = 'Int32'
|
218
|
+
end
|
219
|
+
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
|
220
|
+
case type.to_sym
|
221
|
+
when :integer, :primary_key
|
222
|
+
return 'Int32' unless limit
|
223
|
+
case limit.to_i
|
224
|
+
when 1 then 'Int8'
|
225
|
+
when 2 then 'Int16'
|
226
|
+
when 3, 4 then 'Int32'
|
227
|
+
when 5..8 then 'Int64'
|
228
|
+
else raise ActiveRecord::ActiveRecordError,
|
229
|
+
"No integer type has byte size #{limit}. Use a numeric with precision 0 instead."
|
230
|
+
end
|
231
|
+
# Ignore limit for string and text
|
232
|
+
when :string, :text
|
233
|
+
super(type)
|
234
|
+
else
|
235
|
+
super
|
236
|
+
end
|
237
|
+
end
|
238
|
+
def quote_table_name(name)
|
239
|
+
"`#{name.to_s}`"
|
240
|
+
end
|
241
|
+
def quote_column_name(name)
|
242
|
+
"`#{name.to_s}`"
|
243
|
+
end
|
244
|
+
def create_table(name, options = {})
|
245
|
+
super(name, {options: "ENGINE=MergeTree ORDER BY tuple()"}.merge(options))
|
246
|
+
end
|
247
|
+
alias_method :exec_update_original, :exec_update
|
248
|
+
# exec_insert tries to use Statement.RETURN_GENERATED_KEYS which is not supported by ClickHouse
|
249
|
+
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
|
250
|
+
exec_update_original(sql, name, binds)
|
251
|
+
end
|
252
|
+
# Modify UPDATE statements for ClickHouse specific syntax
|
253
|
+
def exec_update(sql, name, binds)
|
254
|
+
if sql =~ /\AUPDATE (.*) SET (.*)\z/
|
255
|
+
sql = "ALTER TABLE #{$1} UPDATE #{$2}"
|
256
|
+
end
|
257
|
+
exec_update_original(sql, name, binds)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
when 'mariadb'
|
262
|
+
Dir[File.expand_path("mariadb*.jar", 'spec/support/jars')].each do |jdbc_driver_file|
|
263
|
+
require jdbc_driver_file
|
264
|
+
end
|
265
|
+
JDBC_DRIVER = 'org.mariadb.jdbc.Driver'
|
266
|
+
require 'arjdbc/jdbc/adapter'
|
267
|
+
ActiveRecord::ConnectionAdapters::JdbcAdapter.class_eval do
|
268
|
+
def initialize(connection, logger = nil, connection_parameters = nil, config = {})
|
269
|
+
super(connection, logger, config.dup)
|
270
|
+
end
|
271
|
+
def modify_types(types)
|
272
|
+
types[:primary_key] = "integer"
|
273
|
+
types[:integer] = "integer"
|
274
|
+
end
|
275
|
+
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
|
276
|
+
case type.to_sym
|
277
|
+
when :integer, :primary_key
|
278
|
+
return 'integer' unless limit
|
279
|
+
case limit.to_i
|
280
|
+
when 1 then 'tinyint'
|
281
|
+
when 2 then 'smallint'
|
282
|
+
when 3 then 'mediumint'
|
283
|
+
when 4 then 'integer'
|
284
|
+
when 5..8 then 'bigint'
|
285
|
+
else raise ActiveRecord::ActiveRecordError,
|
286
|
+
"No integer type has byte size #{limit}. Use a numeric with precision 0 instead."
|
287
|
+
end
|
288
|
+
when :text
|
289
|
+
case limit
|
290
|
+
when 0..0xff then 'tinytext'
|
291
|
+
when nil, 0x100..0xffff then 'text'
|
292
|
+
when 0x10000..0xffffff then'mediumtext'
|
293
|
+
when 0x1000000..0xffffffff then 'longtext'
|
294
|
+
else raise ActiveRecordError, "No text type has character length #{limit}"
|
295
|
+
end
|
296
|
+
else
|
297
|
+
super
|
298
|
+
end
|
299
|
+
end
|
300
|
+
def quote_table_name(name)
|
301
|
+
"`#{name.to_s}`"
|
302
|
+
end
|
303
|
+
def quote_column_name(name)
|
304
|
+
"`#{name.to_s}`"
|
305
|
+
end
|
306
|
+
def execute(sql, name = nil, binds = nil)
|
307
|
+
exec_update(sql, name, binds)
|
308
|
+
end
|
309
|
+
def create_table(name, options = {})
|
310
|
+
super(name, {options: "ENGINE=Columnstore DEFAULT CHARSET=utf8"}.merge(options))
|
311
|
+
end
|
312
|
+
end
|
91
313
|
end
|
92
314
|
|
93
315
|
puts "==> Using #{MONDRIAN_DRIVER} driver"
|
94
316
|
|
317
|
+
# Necessary for Aggregate optimizations test
|
318
|
+
Java::JavaLang::System.setProperty("mondrian.rolap.EnableInMemoryRollup", "false")
|
319
|
+
|
95
320
|
require 'mondrian/olap'
|
96
321
|
require_relative 'support/matchers/be_like'
|
97
322
|
|
98
323
|
RSpec.configure do |config|
|
99
324
|
config.include Matchers
|
325
|
+
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
|
100
326
|
end
|
101
327
|
|
102
328
|
CATALOG_FILE = File.expand_path('../fixtures/MondrianTest.xml', __FILE__) unless defined?(CATALOG_FILE)
|
103
329
|
|
104
330
|
CONNECTION_PARAMS = if MONDRIAN_DRIVER =~ /^jdbc/
|
105
331
|
{
|
106
|
-
:
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:
|
332
|
+
driver: 'jdbc',
|
333
|
+
jdbc_url: "jdbc:#{MONDRIAN_DRIVER.split('_').last}://#{DATABASE_HOST}/#{DATABASE_NAME}",
|
334
|
+
jdbc_driver: JDBC_DRIVER,
|
335
|
+
username: DATABASE_USER,
|
336
|
+
password: DATABASE_PASSWORD
|
111
337
|
}
|
112
338
|
else
|
113
339
|
{
|
114
|
-
#
|
115
|
-
# :
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
121
|
-
|
340
|
+
# Uncomment to test PostgreSQL SSL connection
|
341
|
+
# properties: {'ssl'=>'true','sslfactory'=>'org.postgresql.ssl.NonValidatingFactory'},
|
342
|
+
driver: MONDRIAN_DRIVER,
|
343
|
+
host: DATABASE_HOST,
|
344
|
+
port: DATABASE_PORT,
|
345
|
+
protocol: DATABASE_PROTOCOL.presence,
|
346
|
+
database: DATABASE_NAME,
|
347
|
+
username: DATABASE_USER,
|
348
|
+
password: DATABASE_PASSWORD
|
349
|
+
}.compact
|
122
350
|
end
|
123
351
|
case MONDRIAN_DRIVER
|
124
352
|
when 'mysql'
|
@@ -130,39 +358,31 @@ end
|
|
130
358
|
case MONDRIAN_DRIVER
|
131
359
|
when 'mysql', 'postgresql'
|
132
360
|
AR_CONNECTION_PARAMS = CONNECTION_PARAMS.slice(:host, :database, :username, :password).merge(
|
133
|
-
:
|
134
|
-
:
|
361
|
+
adapter: MONDRIAN_DRIVER,
|
362
|
+
driver: JDBC_DRIVER,
|
363
|
+
properties: CONNECTION_PARAMS[:properties].dup || {}
|
135
364
|
)
|
136
365
|
when 'oracle'
|
137
366
|
AR_CONNECTION_PARAMS = {
|
138
|
-
:
|
139
|
-
:
|
140
|
-
:
|
141
|
-
:
|
142
|
-
:
|
143
|
-
|
144
|
-
when 'mssql'
|
145
|
-
url = "jdbc:jtds:sqlserver://#{CONNECTION_PARAMS[:host]}/#{CONNECTION_PARAMS[:database]}"
|
146
|
-
url << ";instance=#{DATABASE_INSTANCE}" if DATABASE_INSTANCE
|
147
|
-
AR_CONNECTION_PARAMS = {
|
148
|
-
:adapter => 'jdbc',
|
149
|
-
:dialect => 'Microsoft SQL Server',
|
150
|
-
:driver => JDBC_DRIVER,
|
151
|
-
:url => url,
|
152
|
-
:username => CONNECTION_PARAMS[:username],
|
153
|
-
:password => CONNECTION_PARAMS[:password],
|
154
|
-
:connection_alive_sql => 'SELECT 1'
|
367
|
+
adapter: 'oracle_enhanced',
|
368
|
+
host: CONNECTION_PARAMS[:host],
|
369
|
+
database: CONNECTION_PARAMS[:database],
|
370
|
+
username: CONNECTION_PARAMS[:username],
|
371
|
+
password: CONNECTION_PARAMS[:password],
|
372
|
+
nls_numeric_characters: '.,'
|
155
373
|
}
|
156
374
|
when 'sqlserver'
|
157
375
|
url = "jdbc:sqlserver://#{CONNECTION_PARAMS[:host]};databaseName=#{CONNECTION_PARAMS[:database]};"
|
158
376
|
url << ";instanceName=#{DATABASE_INSTANCE}" if DATABASE_INSTANCE
|
159
377
|
AR_CONNECTION_PARAMS = {
|
160
|
-
:
|
161
|
-
:
|
162
|
-
:
|
163
|
-
:
|
164
|
-
:
|
165
|
-
:
|
378
|
+
adapter: 'jdbc',
|
379
|
+
driver: JDBC_DRIVER,
|
380
|
+
url: url,
|
381
|
+
username: CONNECTION_PARAMS[:username],
|
382
|
+
password: CONNECTION_PARAMS[:password],
|
383
|
+
connection_alive_sql: 'SELECT 1',
|
384
|
+
sqlserver_version: ENV['SQLSERVER_VERSION'],
|
385
|
+
dialect: 'jdbc'
|
166
386
|
}
|
167
387
|
when 'vertica'
|
168
388
|
CONNECTION_PARAMS[:properties] = {
|
@@ -170,11 +390,12 @@ when 'vertica'
|
|
170
390
|
}
|
171
391
|
AR_CONNECTION_PARAMS = {
|
172
392
|
adapter: 'jdbc',
|
173
|
-
driver:
|
174
|
-
url:
|
393
|
+
driver: JDBC_DRIVER,
|
394
|
+
url: "jdbc:#{MONDRIAN_DRIVER}://#{CONNECTION_PARAMS[:host]}/#{CONNECTION_PARAMS[:database]}" \
|
175
395
|
"?SearchPath=#{DATABASE_SCHEMA}", # &LogLevel=DEBUG
|
176
396
|
username: CONNECTION_PARAMS[:username],
|
177
|
-
password: CONNECTION_PARAMS[:password]
|
397
|
+
password: CONNECTION_PARAMS[:password],
|
398
|
+
dialect: 'jdbc'
|
178
399
|
}
|
179
400
|
when 'snowflake'
|
180
401
|
CONNECTION_PARAMS[:database_schema] = DATABASE_SCHEMA
|
@@ -184,30 +405,51 @@ when 'snowflake'
|
|
184
405
|
}
|
185
406
|
AR_CONNECTION_PARAMS = {
|
186
407
|
adapter: 'jdbc',
|
187
|
-
driver:
|
188
|
-
url:
|
408
|
+
driver: JDBC_DRIVER,
|
409
|
+
url: "jdbc:#{MONDRIAN_DRIVER}://#{CONNECTION_PARAMS[:host]}/?db=#{CONNECTION_PARAMS[:database]}" \
|
189
410
|
"&schema=#{DATABASE_SCHEMA}&warehouse=#{WAREHOUSE_NAME}", # &tracing=ALL
|
190
411
|
username: CONNECTION_PARAMS[:username],
|
191
|
-
password: CONNECTION_PARAMS[:password]
|
412
|
+
password: CONNECTION_PARAMS[:password],
|
413
|
+
dialect: 'jdbc'
|
414
|
+
}
|
415
|
+
when 'clickhouse'
|
416
|
+
# CREATE USER mondrian_test IDENTIFIED WITH plaintext_password BY 'mondrian_test';
|
417
|
+
# CREATE DATABASE mondrian_test;
|
418
|
+
# GRANT ALL ON mondrian_test.* TO mondrian_test;
|
419
|
+
|
420
|
+
# For testing different protocols
|
421
|
+
# CONNECTION_PARAMS[:protocol] = 'http'
|
422
|
+
# CONNECTION_PARAMS[:properties] ={'http_connection_provider' => 'APACHE_HTTP_CLIENT'}
|
423
|
+
|
424
|
+
AR_CONNECTION_PARAMS = {
|
425
|
+
adapter: 'jdbc',
|
426
|
+
driver: JDBC_DRIVER,
|
427
|
+
url: "jdbc:ch:#{CONNECTION_PARAMS[:protocol]&.+(':')}//#{CONNECTION_PARAMS[:host]}/#{CONNECTION_PARAMS[:database]}",
|
428
|
+
username: CONNECTION_PARAMS[:username],
|
429
|
+
password: CONNECTION_PARAMS[:password],
|
430
|
+
dialect: 'jdbc'
|
192
431
|
}
|
193
432
|
when /jdbc/
|
194
433
|
AR_CONNECTION_PARAMS = {
|
195
|
-
:
|
196
|
-
:
|
197
|
-
:
|
198
|
-
:
|
199
|
-
:
|
434
|
+
adapter: MONDRIAN_DRIVER =~ /mysql/ ? 'mysql' : 'jdbc',
|
435
|
+
driver: JDBC_DRIVER,
|
436
|
+
url: CONNECTION_PARAMS[:jdbc_url],
|
437
|
+
username: CONNECTION_PARAMS[:username],
|
438
|
+
password: CONNECTION_PARAMS[:password],
|
439
|
+
dialect: MONDRIAN_DRIVER =~ /mysql/ ? 'mysql' : 'jdbc'
|
200
440
|
}
|
201
441
|
else
|
202
442
|
AR_CONNECTION_PARAMS = {
|
203
|
-
:
|
204
|
-
:
|
205
|
-
:
|
206
|
-
|
207
|
-
:
|
443
|
+
adapter: 'jdbc',
|
444
|
+
driver: JDBC_DRIVER,
|
445
|
+
url: "jdbc:#{MONDRIAN_DRIVER}://#{CONNECTION_PARAMS[:host]}" +
|
446
|
+
(CONNECTION_PARAMS[:port] ? ":#{CONNECTION_PARAMS[:port]}" : "") + "/#{CONNECTION_PARAMS[:database]}",
|
447
|
+
username: CONNECTION_PARAMS[:username],
|
448
|
+
password: CONNECTION_PARAMS[:password],
|
449
|
+
dialect: 'jdbc'
|
208
450
|
}
|
209
451
|
end
|
210
452
|
|
211
|
-
CONNECTION_PARAMS_WITH_CATALOG = CONNECTION_PARAMS.merge(:
|
453
|
+
CONNECTION_PARAMS_WITH_CATALOG = CONNECTION_PARAMS.merge(catalog: CATALOG_FILE)
|
212
454
|
|
213
455
|
ActiveRecord::Base.establish_connection(AR_CONNECTION_PARAMS)
|