mondrian-olap 1.1.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 +33 -0
- data/LICENSE-Mondrian.txt +87 -0
- data/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/VERSION +1 -1
- data/lib/mondrian/jars/guava-17.0.jar +0 -0
- 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 +126 -73
- 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 +132 -56
- data/lib/mondrian/olap/schema.rb +9 -3
- data/lib/mondrian/olap/schema_element.rb +6 -3
- data/lib/mondrian/olap/schema_udf.rb +8 -82
- data/lib/mondrian/olap.rb +11 -7
- data/spec/connection_role_spec.rb +4 -1
- data/spec/connection_spec.rb +38 -5
- data/spec/cube_cache_control_spec.rb +7 -17
- data/spec/cube_spec.rb +36 -2
- data/spec/fixtures/MondrianTest.xml +40 -6
- data/spec/fixtures/MondrianTestOracle.xml +40 -6
- data/spec/mondrian_spec.rb +203 -1
- data/spec/query_spec.rb +94 -25
- data/spec/rake_tasks.rb +319 -165
- data/spec/schema_definition_spec.rb +8 -241
- data/spec/spec_helper.rb +330 -112
- data/spec/support/data/customers.csv +10902 -0
- data/spec/support/data/product_classes.csv +101 -0
- data/spec/support/data/products.csv +101 -0
- data/spec/support/data/promotions.csv +11 -0
- data/spec/support/data/sales.csv +101 -0
- data/spec/support/data/time.csv +731 -0
- data/spec/support/data/warehouse.csv +101 -0
- data/spec/support/matchers/be_like.rb +1 -0
- metadata +42 -83
- data/LICENSE-Mondrian.html +0 -259
- data/lib/mondrian/jars/log4j-1.2.17.jar +0 -0
- data/lib/mondrian/jars/log4j.properties +0 -3
- data/lib/mondrian/jars/mondrian-8.3.0.5.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f016aae4b1d6d9f4138ae3bded251944cf7fcfe8f1bd0579df7f962eb1a52d03
|
4
|
+
data.tar.gz: 8b5a4d5c4526f2fd7a239c3dccd57c7d08f5f1d842354fae5bd13f21920e7e73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9b3633a62cef270a163c25c5f1511442938b6705b2385fb2b7e2c2a8f9a1a2041b3f041af0be995970fa86307c4fe1af3c0fb94488c86cc1ec617b93acfe3b
|
7
|
+
data.tar.gz: 82ee663a5017af81ed6089f6f162e6d8a98458c1a7afb50e5bf5c3b27ea7422b91e81cc38e099a0a23d7ae99368b8c425083c55b6a6d1f1b75a04566cc664b0a
|
data/Changelog.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
### 1.3.0 / 2023-06-02
|
2
|
+
|
3
|
+
* New features
|
4
|
+
* Upgrade to the latest Mondrian version 9.3.0.0 with additional patches
|
5
|
+
* Additional Mondrian patches and improvements
|
6
|
+
* Support for ClickHouse database
|
7
|
+
* Support for MariaDB ColumnStore engine
|
8
|
+
* Improve Aggregate performance of large compound slicers when mondrian.rolap.EnableInMemoryRollup=false
|
9
|
+
* Improve performance of Mondrian member property value lookup
|
10
|
+
* Set dynamic Mondrian connection pool size based on mondrian.rolap.maxSqlThreads property
|
11
|
+
* Skip registration of MondrianOlap4jDriver if mondrian.olap4j.registerDriver=false
|
12
|
+
* Enable Mondrian supportsMultiValueInExpr for PostgreSQL and Oracle
|
13
|
+
* Upgrade to log4j2
|
14
|
+
* Support instance parameter for SQL Server connection
|
15
|
+
* Allow to specify high_cardinality for dimension
|
16
|
+
* Remove deprecated jTDS driver support, use MS JDBC driver instead
|
17
|
+
* Remove user defined functions and formatters in JavaScript and CoffeeScript as they are not supported since JVM 8
|
18
|
+
* Upgrade tests to use the later ActiveRecord and RSpec versions
|
19
|
+
* Tested with JRuby 9.4 and JVM 17
|
20
|
+
* Bug fixes
|
21
|
+
* Patch for MONDRIAN-2714 (fixed support for MySQL JDBC driver version 8.0.23)
|
22
|
+
|
23
|
+
### 1.2.0 / 2021-03-06
|
24
|
+
|
25
|
+
* New features
|
26
|
+
* Upgrade to the latest Mondrian version 9.1.0.0
|
27
|
+
* Improved Vertica and Snowflake tests to use bulk data loading
|
28
|
+
* Remove support of LucidDB (which is abandoned a long time ago)
|
29
|
+
* Improve bigint key columns support
|
30
|
+
* Add MySQL 8 JDBC driver support
|
31
|
+
* Tested with JRuby 9.2.14.0
|
32
|
+
* Remove JRuby 1.7 support
|
33
|
+
|
1
34
|
### 1.1.0 / 2019-11-09
|
2
35
|
|
3
36
|
* New features
|
@@ -0,0 +1,87 @@
|
|
1
|
+
Eclipse Public License -v 1.0
|
2
|
+
|
3
|
+
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
4
|
+
|
5
|
+
1. DEFINITIONS
|
6
|
+
|
7
|
+
"Contribution" means:
|
8
|
+
|
9
|
+
a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
|
10
|
+
|
11
|
+
b) in the case of each subsequent Contributor:
|
12
|
+
|
13
|
+
i) changes to the Program, and
|
14
|
+
|
15
|
+
ii) additions to the Program;
|
16
|
+
|
17
|
+
where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
|
18
|
+
|
19
|
+
"Contributor" means any person or entity that distributes the Program.
|
20
|
+
|
21
|
+
"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
|
22
|
+
|
23
|
+
"Program" means the Contributions distributed in accordance with this Agreement.
|
24
|
+
|
25
|
+
"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
|
26
|
+
|
27
|
+
2. GRANT OF RIGHTS
|
28
|
+
|
29
|
+
a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
|
30
|
+
|
31
|
+
b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
|
32
|
+
|
33
|
+
c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
|
34
|
+
|
35
|
+
d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
|
36
|
+
|
37
|
+
3. REQUIREMENTS
|
38
|
+
|
39
|
+
A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
|
40
|
+
|
41
|
+
a) it complies with the terms and conditions of this Agreement; and
|
42
|
+
|
43
|
+
b) its license agreement:
|
44
|
+
|
45
|
+
i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
|
46
|
+
|
47
|
+
ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
|
48
|
+
|
49
|
+
iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
|
50
|
+
|
51
|
+
iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
|
52
|
+
|
53
|
+
When the Program is made available in source code form:
|
54
|
+
|
55
|
+
a) it must be made available under this Agreement; and
|
56
|
+
|
57
|
+
b) a copy of this Agreement must be included with each copy of the Program.
|
58
|
+
|
59
|
+
Contributors may not remove or alter any copyright notices contained within the Program.
|
60
|
+
|
61
|
+
Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
|
62
|
+
|
63
|
+
4. COMMERCIAL DISTRIBUTION
|
64
|
+
|
65
|
+
Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
|
66
|
+
|
67
|
+
For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
|
68
|
+
|
69
|
+
5. NO WARRANTY
|
70
|
+
|
71
|
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
|
72
|
+
|
73
|
+
6. DISCLAIMER OF LIABILITY
|
74
|
+
|
75
|
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
76
|
+
|
77
|
+
7. GENERAL
|
78
|
+
|
79
|
+
If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
|
80
|
+
|
81
|
+
If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
|
82
|
+
|
83
|
+
All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
|
84
|
+
|
85
|
+
Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
|
86
|
+
|
87
|
+
This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -215,8 +215,8 @@ See more examples of dimension and member queries in `spec/cube_spec.rb`.
|
|
215
215
|
|
216
216
|
### User defined MDX functions
|
217
217
|
|
218
|
-
You can define new MDX functions using
|
219
|
-
|
218
|
+
You can define new MDX functions using Ruby that you can later use either in calculated member formulas or in MDX queries.
|
219
|
+
Here are examples of user defined functions in Ruby:
|
220
220
|
|
221
221
|
```ruby
|
222
222
|
schema = Mondrian::OLAP::Schema.define do
|
@@ -273,9 +273,9 @@ See more examples of data access roles in `spec/connection_role_spec.rb`.
|
|
273
273
|
REQUIREMENTS
|
274
274
|
------------
|
275
275
|
|
276
|
-
mondrian-olap gem is compatible with JRuby versions
|
276
|
+
mondrian-olap gem is compatible with JRuby versions 9.3.x and 9.4.x, JVM 8, 11, and 17. mondrian-olap works only with JRuby and not with other Ruby implementations as it includes Mondrian OLAP Java libraries.
|
277
277
|
|
278
|
-
mondrian-olap supports MySQL, PostgreSQL, Oracle,
|
278
|
+
mondrian-olap supports MySQL, PostgreSQL, Oracle, Microsoft SQL Server, Vertica, Snowflake, and ClickHouse databases as well as other databases that are supported by Mondrian OLAP engine (using jdbc_driver and jdbc_url connection parameters). When using MySQL or PostgreSQL databases then install jdbc-mysql or jdbc-postgres gem and require "jdbc/mysql" or "jdbc/postgres" to load the corresponding JDBC database driver. When using Oracle then require Oracle JDBC driver `ojdbc*.jar`. When using MS SQL Server you then use the Microsoft JDBC driver `mssql-jdbc-*.jar`. When using Vertica, Snowflake, or ClickHouse then require corresponding JDBC drivers.
|
279
279
|
|
280
280
|
INSTALL
|
281
281
|
-------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -289,102 +289,148 @@ module Mondrian
|
|
289
289
|
true
|
290
290
|
end
|
291
291
|
|
292
|
+
def jdbc_uri
|
293
|
+
if respond_to?(method_name = "jdbc_uri_#{@driver}", true)
|
294
|
+
send method_name
|
295
|
+
else
|
296
|
+
raise ArgumentError, 'unknown JDBC driver'
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
292
300
|
private
|
293
301
|
|
294
302
|
def connection_string
|
295
303
|
string = "jdbc:mondrian:Jdbc=#{quote_string(jdbc_uri)};JdbcDrivers=#{jdbc_driver};"
|
296
304
|
# by default use content checksum to reload schema when catalog has changed
|
297
|
-
string
|
298
|
-
string
|
305
|
+
string += "UseContentChecksum=true;" unless @params[:use_content_checksum] == false
|
306
|
+
string += "PinSchemaTimeout=#{@params[:pin_schema_timeout]};" if @params[:pin_schema_timeout]
|
299
307
|
if role = @params[:role] || @params[:roles]
|
300
308
|
roles = Array(role).map{|r| r && r.to_s.gsub(',', ',,')}.compact
|
301
|
-
string
|
309
|
+
string += "Role=#{quote_string(roles.join(','))};" unless roles.empty?
|
302
310
|
end
|
303
311
|
if locale = @params[:locale]
|
304
|
-
string
|
312
|
+
string += "Locale=#{quote_string(locale.to_s)};"
|
305
313
|
end
|
306
|
-
string
|
314
|
+
string + (@params[:catalog] ? "Catalog=#{catalog_uri}" : "CatalogContent=#{quote_string(catalog_content)}")
|
307
315
|
end
|
308
316
|
|
309
|
-
def
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
317
|
+
def jdbc_uri_generic(options = {})
|
318
|
+
uri_prefix = options[:uri_prefix] || "jdbc:#{@driver}://"
|
319
|
+
port = @params[:port] || options[:default_port]
|
320
|
+
uri = "#{uri_prefix}#{@params[:host]}#{port && ":#{port}"}"
|
321
|
+
uri += "/#{@params[:database]}" if @params[:database] && options[:add_database] != false
|
322
|
+
properties = new_empty_properties
|
323
|
+
properties.merge!(options[:default_properties]) if options[:default_properties].is_a?(Hash)
|
324
|
+
properties.merge!(@params[:properties]) if @params[:properties].is_a?(Hash)
|
325
|
+
"#{uri}#{uri_properties_string(properties, options[:separator], options[:first_separator])}"
|
326
|
+
end
|
327
|
+
|
328
|
+
def new_empty_properties
|
329
|
+
# If ActiveSupport::HashWithIndifferentAccess is present then treat symbol and string keys as equal
|
330
|
+
defined?(ActiveSupport::HashWithIndifferentAccess) ? ActiveSupport::HashWithIndifferentAccess.new : {}
|
331
|
+
end
|
332
|
+
|
333
|
+
def uri_properties_string(properties, separator = nil, first_separator = nil)
|
334
|
+
properties_string = properties.map { |k, v| "#{k}=#{v}" }.join(separator || '&')
|
335
|
+
unless properties_string.empty?
|
336
|
+
first_separator ||= '?'
|
337
|
+
"#{first_separator}#{properties_string}"
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def jdbc_uri_mysql
|
342
|
+
jdbc_uri_generic(default_properties: {useUnicode: true, characterEncoding: 'UTF-8'})
|
343
|
+
end
|
344
|
+
|
345
|
+
alias_method :jdbc_uri_postgresql, :jdbc_uri_generic
|
346
|
+
alias_method :jdbc_uri_vertica, :jdbc_uri_generic
|
347
|
+
alias_method :jdbc_uri_mariadb, :jdbc_uri_generic
|
348
|
+
|
349
|
+
def jdbc_uri_oracle
|
350
|
+
# connection using TNS alias
|
351
|
+
if @params[:database] && !@params[:host] && !@params[:url] && ENV['TNS_ADMIN']
|
352
|
+
"jdbc:oracle:thin:@#{@params[:database]}"
|
353
|
+
else
|
354
|
+
@params[:url] || begin
|
355
|
+
database = @params[:database]
|
356
|
+
unless database =~ %r{^(:|/)}
|
357
|
+
# assume database is a SID if no colon or slash are supplied (backward-compatibility)
|
358
|
+
database = ":#{database}"
|
331
359
|
end
|
360
|
+
"jdbc:oracle:thin:@#{@params[:host] || 'localhost'}:#{@params[:port] || 1521}#{database}"
|
332
361
|
end
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
if
|
355
|
-
|
356
|
-
uri << properties.map{|k, v| "#{k}=#{v}"}.join('&')
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
JDBC_SQLSERVER_PARAM_PROPERTIES = {
|
366
|
+
database: 'databaseName',
|
367
|
+
integrated_security: 'integratedSecurity',
|
368
|
+
application_name: 'applicationName',
|
369
|
+
instance_name: 'instanceName',
|
370
|
+
instance: 'instanceName'
|
371
|
+
}
|
372
|
+
|
373
|
+
def jdbc_uri_sqlserver
|
374
|
+
jdbc_uri_generic(
|
375
|
+
uri_prefix: 'jdbc:sqlserver://', add_database: false, separator: ';', first_separator: ';',
|
376
|
+
default_properties: uri_default_param_properties(JDBC_SQLSERVER_PARAM_PROPERTIES)
|
377
|
+
)
|
378
|
+
end
|
379
|
+
|
380
|
+
def uri_default_param_properties(param_properties)
|
381
|
+
default_properties = {}
|
382
|
+
param_properties.each do |key, property|
|
383
|
+
if value = @params[key]
|
384
|
+
default_properties[property] = value
|
357
385
|
end
|
358
|
-
uri
|
359
|
-
when 'jdbc'
|
360
|
-
@params[:jdbc_url] or raise ArgumentError, 'missing jdbc_url parameter'
|
361
|
-
else
|
362
|
-
raise ArgumentError, 'unknown JDBC driver'
|
363
386
|
end
|
387
|
+
default_properties
|
388
|
+
end
|
389
|
+
|
390
|
+
JDBC_SNOWFLAKE_PARAM_PROPERTIES = {
|
391
|
+
database: 'db',
|
392
|
+
database_schema: 'schema',
|
393
|
+
warehouse: 'warehouse'
|
394
|
+
}
|
395
|
+
|
396
|
+
def jdbc_uri_snowflake
|
397
|
+
jdbc_uri_generic(
|
398
|
+
add_database: false, separator: '&', first_separator: '/?',
|
399
|
+
default_properties: uri_default_param_properties(JDBC_SNOWFLAKE_PARAM_PROPERTIES)
|
400
|
+
)
|
364
401
|
end
|
365
402
|
|
403
|
+
def jdbc_uri_clickhouse
|
404
|
+
protocol_prefix = if protocol = @params[:protocol]
|
405
|
+
raise ArgumentError, "invalid protocol #{protocol}" unless protocol =~ /\A\w+\z/
|
406
|
+
":#{protocol}"
|
407
|
+
end
|
408
|
+
uri_prefix = "jdbc:ch#{protocol_prefix}://"
|
409
|
+
jdbc_uri_generic(uri_prefix: uri_prefix)
|
410
|
+
end
|
411
|
+
|
412
|
+
def jdbc_uri_jdbc
|
413
|
+
@params[:jdbc_url] or raise ArgumentError, 'missing jdbc_url parameter'
|
414
|
+
end
|
415
|
+
|
416
|
+
JDBC_DRIVER_CLASS = {
|
417
|
+
'postgresql' => 'org.postgresql.Driver',
|
418
|
+
'oracle' => 'oracle.jdbc.OracleDriver',
|
419
|
+
'sqlserver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
420
|
+
'vertica' => 'com.vertica.jdbc.Driver',
|
421
|
+
'snowflake' => 'net.snowflake.client.jdbc.SnowflakeDriver',
|
422
|
+
'clickhouse' => 'com.clickhouse.jdbc.ClickHouseDriver',
|
423
|
+
'mariadb' => 'org.mariadb.jdbc.Driver'
|
424
|
+
}
|
425
|
+
|
366
426
|
def jdbc_driver
|
367
427
|
case @driver
|
368
428
|
when 'mysql'
|
369
|
-
'com.mysql.jdbc.Driver'
|
370
|
-
when 'postgresql'
|
371
|
-
'org.postgresql.Driver'
|
372
|
-
when 'oracle'
|
373
|
-
'oracle.jdbc.OracleDriver'
|
374
|
-
when 'luciddb'
|
375
|
-
'org.luciddb.jdbc.LucidDbClientDriver'
|
376
|
-
when 'mssql'
|
377
|
-
'net.sourceforge.jtds.jdbc.Driver'
|
378
|
-
when 'sqlserver'
|
379
|
-
'com.microsoft.sqlserver.jdbc.SQLServerDriver'
|
380
|
-
when 'vertica'
|
381
|
-
'com.vertica.jdbc.Driver'
|
382
|
-
when 'snowflake'
|
383
|
-
'net.snowflake.client.jdbc.SnowflakeDriver'
|
429
|
+
(Java::com.mysql.cj.jdbc.Driver rescue nil) ? 'com.mysql.cj.jdbc.Driver' : 'com.mysql.jdbc.Driver'
|
384
430
|
when 'jdbc'
|
385
431
|
@params[:jdbc_driver] or raise ArgumentError, 'missing jdbc_driver parameter'
|
386
432
|
else
|
387
|
-
raise ArgumentError, 'unknown JDBC driver'
|
433
|
+
JDBC_DRIVER_CLASS[@driver] or raise ArgumentError, 'unknown JDBC driver'
|
388
434
|
end
|
389
435
|
end
|
390
436
|
|
@@ -434,6 +480,9 @@ module Mondrian
|
|
434
480
|
end
|
435
481
|
end
|
436
482
|
|
483
|
+
# Starting from Mondrian 9.2 additional QueryBody plan string is added at the end which will be ignored.
|
484
|
+
QUERY_BODY_PLAN_REGEXP = /\AQueryBody:/
|
485
|
+
|
437
486
|
class ProfilingHandler
|
438
487
|
java_implements Java::mondrian.spi.ProfileHandler
|
439
488
|
attr_reader :plan
|
@@ -441,7 +490,11 @@ module Mondrian
|
|
441
490
|
|
442
491
|
java_signature 'void explain(String plan, mondrian.olap.QueryTiming timing)'
|
443
492
|
def explain(plan, timing)
|
444
|
-
@plan
|
493
|
+
if @plan
|
494
|
+
@plan += "\n" + plan unless plan =~ QUERY_BODY_PLAN_REGEXP
|
495
|
+
else
|
496
|
+
@plan = plan
|
497
|
+
end
|
445
498
|
@timing = timing
|
446
499
|
end
|
447
500
|
end
|
data/lib/mondrian/olap/cube.rb
CHANGED
@@ -56,15 +56,35 @@ module Mondrian
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def dimensions
|
59
|
-
@dimenstions ||= @raw_cube.getDimensions.map{|d|
|
59
|
+
@dimenstions ||= @raw_cube.getDimensions.map { |d| dimension_from_raw(d) }
|
60
60
|
end
|
61
61
|
|
62
62
|
def dimension_names
|
63
|
-
dimensions.map
|
63
|
+
dimensions.map(&:name)
|
64
64
|
end
|
65
65
|
|
66
66
|
def dimension(name)
|
67
|
-
dimensions
|
67
|
+
if @dimensions
|
68
|
+
@dimensions.detect { |d| d.name == name }
|
69
|
+
elsif raw_dimension = @raw_cube.getDimensions.detect { |d| d.getName == name }
|
70
|
+
dimension_from_raw(raw_dimension)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def hierarchies
|
75
|
+
@hierarchies ||= @raw_cube.getHierarchies.map { |h| hierarchy_from_raw(h) }
|
76
|
+
end
|
77
|
+
|
78
|
+
def hierarchy_names
|
79
|
+
hierarchies.map(&:name)
|
80
|
+
end
|
81
|
+
|
82
|
+
def hierarchy(name)
|
83
|
+
if @hierarchies
|
84
|
+
@hierarchies.detect { |h| h.name == name }
|
85
|
+
elsif raw_hierarchy = @raw_cube.getHierarchies.detect { |h| h.getName == name }
|
86
|
+
hierarchy_from_raw(raw_hierarchy)
|
87
|
+
end
|
68
88
|
end
|
69
89
|
|
70
90
|
def query
|
@@ -85,6 +105,16 @@ module Mondrian
|
|
85
105
|
|
86
106
|
def_delegators :@cache_control, :flush_region_cache_with_segments, :flush_region_cache_with_segments
|
87
107
|
def_delegators :@cache_control, :flush_region_cache_with_full_names, :flush_region_cache_with_full_names
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def dimension_from_raw(raw_dimension)
|
112
|
+
Dimension.new(self, raw_dimension)
|
113
|
+
end
|
114
|
+
|
115
|
+
def hierarchy_from_raw(raw_hierarchy)
|
116
|
+
Hierarchy.new(dimension_from_raw(raw_hierarchy.getDimension), raw_hierarchy)
|
117
|
+
end
|
88
118
|
end
|
89
119
|
|
90
120
|
class Dimension
|
@@ -156,7 +186,7 @@ module Mondrian
|
|
156
186
|
@raw_hierarchy = raw_hierarchy
|
157
187
|
end
|
158
188
|
|
159
|
-
attr_reader :raw_hierarchy
|
189
|
+
attr_reader :raw_hierarchy, :dimension
|
160
190
|
|
161
191
|
def name
|
162
192
|
@name ||= @raw_hierarchy.getName
|
@@ -170,6 +200,10 @@ module Mondrian
|
|
170
200
|
@caption ||= @raw_hierarchy.getCaption
|
171
201
|
end
|
172
202
|
|
203
|
+
def dimension_name
|
204
|
+
@dimension.name
|
205
|
+
end
|
206
|
+
|
173
207
|
def levels
|
174
208
|
@levels = @raw_hierarchy.getLevels.map{|l| Level.new(self, l)}
|
175
209
|
end
|
@@ -257,6 +291,10 @@ module Mondrian
|
|
257
291
|
@cardinality = @raw_level.getCardinality
|
258
292
|
end
|
259
293
|
|
294
|
+
def cardinality=(value)
|
295
|
+
mondrian_level.setApproxRowCount(value || Java::JavaLang::Integer::MIN_VALUE)
|
296
|
+
end
|
297
|
+
|
260
298
|
def members_count
|
261
299
|
@members_count ||= begin
|
262
300
|
if cardinality >= 0
|
@@ -275,6 +313,10 @@ module Mondrian
|
|
275
313
|
end
|
276
314
|
end
|
277
315
|
|
316
|
+
def mondrian_level
|
317
|
+
@raw_level.unwrap(Java::MondrianOlap::Level.java_class)
|
318
|
+
end
|
319
|
+
|
278
320
|
include Annotated
|
279
321
|
def annotations
|
280
322
|
annotations_for(@raw_level)
|
data/lib/mondrian/olap/error.rb
CHANGED
@@ -39,7 +39,7 @@ module Mondrian
|
|
39
39
|
|
40
40
|
def profiling_timing_string
|
41
41
|
if profiling_timing && (timing_string = profiling_timing.toString)
|
42
|
-
timing_string.gsub("\r\n", "\n")
|
42
|
+
timing_string.gsub("\r\n", "\n").sub(Mondrian::OLAP::Result::QUERY_TIMING_CUMULATIVE_REGEXP, '')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -76,7 +76,15 @@ module Mondrian
|
|
76
76
|
f.accessible = true
|
77
77
|
if cell_set = f.value(statement)
|
78
78
|
cell_set.close
|
79
|
-
|
79
|
+
# Starting from Mondrian 9.2 query plan was not available in case of error, need to get it explicitly.
|
80
|
+
if (@profiling_handler = statement.getProfileHandler) && !@profiling_handler.timing
|
81
|
+
query = statement.getQuery
|
82
|
+
string_writer = Java::java.io.StringWriter.new
|
83
|
+
print_writer = Java::java.io.PrintWriter.new(string_writer)
|
84
|
+
query.explain(print_writer)
|
85
|
+
print_writer.close
|
86
|
+
@profiling_handler.explain(string_writer.toString, cell_set.getQueryTiming)
|
87
|
+
end
|
80
88
|
end
|
81
89
|
end
|
82
90
|
end
|
data/lib/mondrian/olap/query.rb
CHANGED
@@ -296,6 +296,7 @@ module Mondrian
|
|
296
296
|
}
|
297
297
|
|
298
298
|
def members_to_mdx(members)
|
299
|
+
members ||= []
|
299
300
|
# if only one member which does not end with ] or .Item(...)
|
300
301
|
# then assume it is expression which returns set
|
301
302
|
# TODO: maybe always include also single expressions in {...} to avoid some edge cases?
|