Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
olapy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
olapy
Commits
783f7d63
Commit
783f7d63
authored
Jul 17, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tests
parent
985bf2ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
35 deletions
+146
-35
olapy/test_parsing_queries.py
olapy/test_parsing_queries.py
+0
-35
tests/test_parsing_queries.py
tests/test_parsing_queries.py
+146
-0
No files found.
olapy/test_parsing_queries.py
deleted
100644 → 0
View file @
985bf2ad
from
__future__
import
absolute_import
,
division
,
print_function
from
olapy.core.mdx.executor.execute
import
MdxEngine
CUBE
=
'sales'
query1
=
"""SELECT
{[Measures].[Amount]} ON COLUMNS
FROM [sales]"""
where1
=
"Where [Time].[Calendar].[Day].[May 12,2010]"
executer
=
MdxEngine
(
CUBE
)
def
test_parsing_query1
():
query_parts
=
executer
.
decorticate_query
(
query1
)
assert
query_parts
[
'all'
]
==
[[
'Measures'
,
'Amount'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Measures'
,
'Amount'
]]
query1_where
=
query1
+
'
\
n
'
+
where1
query_parts
=
executer
.
decorticate_query
(
query1_where
)
assert
query_parts
[
'all'
]
==
[[
'Measures'
,
'Amount'
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Measures'
,
'Amount'
]]
tests/test_parsing_queries.py
0 → 100644
View file @
783f7d63
from
__future__
import
absolute_import
,
division
,
print_function
from
olapy.core.mdx.executor.execute
import
MdxEngine
CUBE
=
'sales'
query1
=
"""SELECT
{[Measures].[Amount]} ON COLUMNS
FROM [sales]"""
query2
=
"""SELECT
{[Geography].[Economy].[Partnership]} ON COLUMNS
FROM [sales]"""
query3
=
"""SELECT
non empty {[Geography].[Geo].[Country].members} ON COLUMNS,
{[Measures].[Amount]} ON ROWS
FROM [sales]"""
query4
=
"""SELECT
{[Geography].[Economy].[Partnership]} ON COLUMNS,
non empty {[Geography].[Geo].[Country].members} ON ROWS
from [sales]"""
query5
=
"""select
{[Geography].[Economy].[Country]} on 0,
non empty {[Geography].[Geo].[Country].members} on 1
from [sales]"""
query6
=
"""select
{[Geography].[Economy].[Partnership]} on 0,
{[Product].[Prod].[Company]} on 1
from [sales]"""
query7
=
"""select
{[Geography].[Economy].[Partnership].[EU]} on 0,
{[Product].[Prod].[Company].[Crazy Development]} on 1
from [sales]"""
query8
=
"""select
{[Geography].[Economy].[Partnership].[EU],
[Geography].[Economy].[Partnership].[None],
[Geography].[Economy].[Partnership].[NAFTA]} on 0,
{[Product].[Prod].[Company].[Crazy Development],
[Product].[Prod].[Company].[Company_test],
[Product].[Prod].[Company].[test_Development]} on 1
from [sales]"""
query9
=
"""select
{[Geography].[Economy].[Partnership].[EU],
[Geography].[Economy].[Partnership].[None]} on 0
from [sales]"""
query10
=
"""select
{[Geography].[Geo].[Country].[France],
[Geography].[Geo].[Country].[Spain]} on 0,
non empty {[Measures].[Amount]} on 1
from [sales]"""
where
=
"Where [Time].[Calendar].[Day].[May 12,2010]"
query11
=
"""
SELECT NON EMPTY Hierarchize(AddCalculatedMembers(DrilldownMember({{DrilldownMember({{DrilldownMember({{
[Time].[Time].[Year].Members}}, {
[Time].[Time].[Year].[2010]})}}, {
[Time].[Time].[Quarter].[2010].[Q2 2010]})}}, {
[Time].[Time].[Month].[2010].[Q2 2010].[May 2010]}))) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME
ON COLUMNS
FROM [sales] WHERE ([Measures].[Amount])
CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
"""
query12
=
"""SELECT NON EMPTY Hierarchize(AddCalculatedMembers({
[Geography].[Geography].[Continent].Members}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS
FROM [sales]
WHERE ([Measures].[Amount])
CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS"""
executer
=
MdxEngine
(
CUBE
)
def
test_parsing_query1
():
query_parts
=
executer
.
decorticate_query
(
query1
)
assert
query_parts
[
'all'
]
==
[[
'Measures'
,
'Amount'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Measures'
,
'Amount'
]]
query_parts
=
executer
.
decorticate_query
(
query1
+
'
\
n
'
+
where
)
assert
query_parts
[
'all'
]
==
[[
'Measures'
,
'Amount'
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Measures'
,
'Amount'
]]
def
test_parsing_query2
():
query_parts
=
executer
.
decorticate_query
(
query2
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
]]
query_parts
=
executer
.
decorticate_query
(
query2
+
'
\
n
'
+
where
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
]]
def
test_parsing_query3
():
query_parts
=
executer
.
decorticate_query
(
query3
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Geo'
,
'Country'
,
''
],
[
'Measures'
,
'Amount'
]]
assert
query_parts
[
'rows'
]
==
[[
'Measures'
,
'Amount'
]]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Geo'
,
'Country'
,
''
]]
query_parts
=
executer
.
decorticate_query
(
query3
+
'
\
n
'
+
where
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Geo'
,
'Country'
,
''
],
[
'Measures'
,
'Amount'
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'rows'
]
==
[[
'Measures'
,
'Amount'
]]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Geo'
,
'Country'
,
''
]]
def
test_parsing_query4
():
query_parts
=
executer
.
decorticate_query
(
query4
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
],
[
'Geography'
,
'Geo'
,
'Country'
,
''
]]
assert
query_parts
[
'rows'
]
==
[[
'Geography'
,
'Geo'
,
'Country'
,
''
]]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
]]
query_parts
=
executer
.
decorticate_query
(
query4
+
'
\
n
'
+
where
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
],
[
'Geography'
,
'Geo'
,
'Country'
,
''
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'rows'
]
==
[[
'Geography'
,
'Geo'
,
'Country'
,
''
]]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
]]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment