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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
olapy
Commits
96d344b0
Commit
96d344b0
authored
May 04, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update docs
parent
ba244848
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
98 deletions
+104
-98
docs/api.rst
docs/api.rst
+8
-16
olapy/core/mdx/executor/execute.py
olapy/core/mdx/executor/execute.py
+81
-66
olapy/core/services/xmla.py
olapy/core/services/xmla.py
+2
-2
olapy/core/services/xmla_execute_tools.py
olapy/core/services/xmla_execute_tools.py
+13
-14
No files found.
docs/api.rst
View file @
96d344b0
...
@@ -32,19 +32,20 @@ to import the package use::
...
@@ -32,19 +32,20 @@ to import the package use::
.. autoclass:: MdxEngine
.. autoclass:: MdxEngine
:members:
:members:
get_cubes_names,
get_cubes_names,
get_cube,
load_tables,
get_measures,
get_star_schema_dataframe,
get_all_tables_names,
get_all_tables_names,
get_cube,
get_cube,
get_
measur
es,
get_
tupl
es,
load_tables
,
decorticate_query
,
change_measures,
change_measures,
get_tables_and_columns,
get_tables_and_columns,
execute_one_tuple,
execute_one_tuple,
add_missed_column,
add_missed_column,
update_columns_to_keep,
execute_mdx
execute_mdx
**MdxEngine.load_star_schema_dataframe** contains a DataFrame of all dimension merged in one (the star schema in one table)
Package ``olapy.core.services.xmla``
Package ``olapy.core.services.xmla``
------------------------------------
------------------------------------
...
@@ -57,7 +58,6 @@ to import the package use::
...
@@ -57,7 +58,6 @@ to import the package use::
.. autoclass:: XmlaProviderService
.. autoclass:: XmlaProviderService
:members:
:members:
change_catalogue,
Discover,
Discover,
Execute
Execute
...
@@ -74,18 +74,10 @@ to import the package use::
...
@@ -74,18 +74,10 @@ to import the package use::
.. autoclass:: XmlaExecuteTools
.. autoclass:: XmlaExecuteTools
:members:
:members:
split_
DataF
rame,
split_
dataf
rame,
get_tuple_without_nan,
get_tuple_without_nan,
check_measures_only_selected,
generate_xs0_measures_only,
generate_xs0,
generate_xs0,
generate_cell_info,
generate_cell_data,
generate_cell_data,
generate_axes_info,
generate_axes_info,
generate_slicer_axis
generate_slicer_axis
.. automodule:: olapy.core.services.logger
.. autoclass:: Logs
:members:
write_log
\ No newline at end of file
olapy/core/mdx/executor/execute.py
View file @
96d344b0
...
@@ -58,10 +58,10 @@ class MdxEngine:
...
@@ -58,10 +58,10 @@ class MdxEngine:
# to get cubes in db
# to get cubes in db
self
.
_
=
self
.
get_cubes_names
()
self
.
_
=
self
.
get_cubes_names
()
self
.
tables_loaded
=
self
.
_
load_tables
()
self
.
tables_loaded
=
self
.
load_tables
()
# all measures
# all measures
self
.
measures
=
self
.
_
get_measures
()
self
.
measures
=
self
.
get_measures
()
self
.
load_star_schema_dataframe
=
self
.
_
get_star_schema_dataframe
(
self
.
load_star_schema_dataframe
=
self
.
get_star_schema_dataframe
(
cube_name
)
cube_name
)
self
.
tables_names
=
self
.
_get_tables_name
()
self
.
tables_names
=
self
.
_get_tables_name
()
# default measure is the first one
# default measure is the first one
...
@@ -70,7 +70,7 @@ class MdxEngine:
...
@@ -70,7 +70,7 @@ class MdxEngine:
@
classmethod
@
classmethod
def
get_cubes_names
(
cls
):
def
get_cubes_names
(
cls
):
'''
'''
:return: list cubes name that exists in cubes folder
and postgres database
:return: list cubes name that exists in cubes folder
(under ~/olapy-data/cubes) and postgres database (if connected)
'''
'''
# get csv files folders (cubes)
# get csv files folders (cubes)
...
@@ -195,9 +195,9 @@ class MdxEngine:
...
@@ -195,9 +195,9 @@ class MdxEngine:
]]
]]
return
tables
return
tables
def
_
load_tables
(
self
):
def
load_tables
(
self
):
"""
"""
load all tables
(DataFrames)
load all tables
{ Table name : DataFrame } of the current cube instance
:return: dict with key as table name and DataFrame as value
:return: dict with key as table name and DataFrame as value
"""
"""
...
@@ -219,7 +219,7 @@ class MdxEngine:
...
@@ -219,7 +219,7 @@ class MdxEngine:
return
tables
return
tables
def
_
get_measures
(
self
):
def
get_measures
(
self
):
"""
"""
:return: all numerical columns in facts table
:return: all numerical columns in facts table
...
@@ -315,7 +315,7 @@ class MdxEngine:
...
@@ -315,7 +315,7 @@ class MdxEngine:
return
fusion
return
fusion
def
_
get_star_schema_dataframe
(
self
,
cube_name
):
def
get_star_schema_dataframe
(
self
,
cube_name
):
"""
"""
merge all DataFrames as star schema
merge all DataFrames as star schema
...
@@ -357,7 +357,7 @@ class MdxEngine:
...
@@ -357,7 +357,7 @@ class MdxEngine:
def
get_cube
(
self
):
def
get_cube
(
self
):
"""
"""
get path to the cube (example /home_directory/
your_user_name/
olapy-data/cubes)
get path to the cube (example /home_directory/olapy-data/cubes)
:return: path to the cube
:return: path to the cube
"""
"""
...
@@ -372,21 +372,18 @@ class MdxEngine:
...
@@ -372,21 +372,18 @@ class MdxEngine:
example:
example:
SELECT {[Geography].[Geography].[All Continent].Members,
SELECT
{[Geography].[Geography].[All Continent].Members,
[Geography].[Geography].[Continent].[Europe]
[Geography].[Geography].[Continent].[Europe]} ON COLUMNS,
} ON COLUMNS,
{[Product].[Product].[Company]} ON ROWS
{[Product].[Product].[Company]
FROM {sales}
} ON ROWS
it returns :
FROM {sales}
[['Geography','Geography','Continent'],
['Geography','Geography','Continent','Europe'],
It returns [ ['Geography','Geography','Continent'],
['Product','Product','Company']]
['Geography','Geography','Continent','Europe'],
['Product','Product','Company']
]
:param query: mdx query
:param query: mdx query
...
@@ -522,37 +519,40 @@ class MdxEngine:
...
@@ -522,37 +519,40 @@ class MdxEngine:
def execute_one_tuple(self, tuple_as_list, Dataframe_in, columns_to_keep):
def execute_one_tuple(self, tuple_as_list, Dataframe_in, columns_to_keep):
"""
"""
filter a DataFrame (Dataframe_in) with one tuple
filter a DataFrame (Dataframe_in) with one tuple
Example :
Example ::
tuple = ['Geography','Geography','Continent','Europe','France','olapy']
Dataframe_in in =
tuple = ['Geography','Geography','Continent','Europe','France','olapy']
+-------------+----------+---------+---------+---------+
Dataframe_in in :
| Continent | Country | Company | Article | Amount |
+=============+==========+=========+=========+=========+
+-------------+----------+---------+---------+---------+
| America | US | MS | SSAS | 35150 |
| Continent | Country | Company | Article | Amount |
+-------------+----------+---------+---------+---------+
+=============+==========+=========+=========+=========+
| Europe | France | AB | olapy | 41239 |
| America | US | MS | SSAS | 35150 |
+-------------+----------+---------+---------+---------+
+-------------+----------+---------+---------+---------+
| ..... | ..... | ...... | ..... | ..... |
| Europe | France | AB | olapy | 41239 |
+-------------+----------+---------+---------+---------+
+-------------+----------+---------+---------+---------+
| ..... | ..... | ...... | ..... | ..... |
out :
+-------------+----------+---------+---------+---------+
+-------------+----------+---------+---------+---------+
out :
| Continent | Country | Company | Article | Amount |
+=============+==========+=========+=========+=========+
+-------------+----------+---------+---------+---------+
| Europe | France | AB | olapy | 41239 |
| Continent | Country | Company | Article | Amount |
+-------------+----------+---------+---------+---------+
+=============+==========+=========+=========+=========+
| Europe | France | AB | olapy | 41239 |
+-------------+----------+---------+---------+---------+
:param tuple_as_list: tuple as list
:param tuple_as_list: tuple as list
:param Dataframe_in: DataFrame in with you want to execute tuple
:param Dataframe_in: DataFrame in with you want to execute tuple
:param columns_to_keep: (useful for executing many tuples, for instance execute_mdx)
:param columns_to_keep: (useful for executing many tuples, for instance execute_mdx)
other columns to keep in the execution except the current tuple
other columns to keep in the execution except the current tuple
:return: Filtered DataFrame
:return: Filtered DataFrame
"""
"""
df = Dataframe_in
df = Dataframe_in
...
@@ -660,35 +660,50 @@ class MdxEngine:
...
@@ -660,35 +660,50 @@ class MdxEngine:
def update_columns_to_keep(self, tuple_as_list, columns_to_keep):
def update_columns_to_keep(self, tuple_as_list, columns_to_keep):
"""
"""
If we have multiple dimensions, with many columns like
if we have multiple dimensions, with many columns like:
columns_to_keep =>
( Geo -> Continent,Country
columns_to_keep :
Prod -> Company
Time -> Year,Month,Day
Geo -> Continent,Country
)
Prod -> Company
Time -> Year,Month,Day
we have to use only dimension's columns of current dimension that exist in tuple_as_list a keep other dimensions
we have to use only dimension's columns of current dimension that exist in tuple_as_list a keep other dimensions
columns
columns
so if tuple_as_list = ['Geography','Geography','Continent']
so if tuple_as_list = ['Geography','Geography','Continent']
columns_to_keep will be
columns_to_keep will be
:
columns_to_keep =>
columns_to_keep :
Geo -> Continent
Prod -> Company
Time -> Year,Month,Day
( Geo -> Continent
we need columns_to_keep for grouping our columns in the DataFrame
Prod -> Company
Time -> Year,Month,Day
)
(we need columns_to_keep for grouping our columns in the DataFrame)
:param tuple_as_list:
example :
:param tuple_as_list: example -> ['Geography','Geography','Continent']
['Geography','Geography','Continent']
:param columns_to_keep: example -> { 'Geography' : ['Continent','Country'],
:param columns_to_keep:
'Time' : ['Year','Month','Day']
}
example :
{
'Geography':
['Continent','Country'],
'Time':
['Year','Month','Day']
}
:return: updated columns_to_keep
:return: updated columns_to_keep
"""
"""
...
...
olapy/core/services/xmla.py
View file @
96d344b0
...
@@ -55,7 +55,7 @@ class XmlaProviderService(ServiceBase):
...
@@ -55,7 +55,7 @@ class XmlaProviderService(ServiceBase):
the first principle function of xmla protocol
the first principle function of xmla protocol
:param request: Discover function must take 3 argument ( JUST 3 ! ) RequestType,
:param request: Discover function must take 3 argument ( JUST 3 ! ) RequestType,
Restrictions and Properties , we encapsulate them in DiscoverRequest object
Restrictions and Properties , we encapsulate them in DiscoverRequest object
:return: Discover response in xmla format
:return: Discover response in xmla format
...
@@ -144,7 +144,7 @@ class XmlaProviderService(ServiceBase):
...
@@ -144,7 +144,7 @@ class XmlaProviderService(ServiceBase):
the second principle function of xmla protocol
the second principle function of xmla protocol
:param request: Execute function must take 2 argument ( JUST 2 ! ) Command and Properties,
:param request: Execute function must take 2 argument ( JUST 2 ! ) Command and Properties,
we encapsulate them in ExecuteRequest object
we encapsulate them in ExecuteRequest object
:return: Execute response in xml format
:return: Execute response in xml format
"""
"""
...
...
olapy/core/services/xmla_execute_tools.py
View file @
96d344b0
...
@@ -16,6 +16,7 @@ class XmlaExecuteTools():
...
@@ -16,6 +16,7 @@ class XmlaExecuteTools():
def
split_dataframe
(
mdx_execution_result
):
def
split_dataframe
(
mdx_execution_result
):
"""
"""
Split DataFrame into multiple ones by dimension
Split DataFrame into multiple ones by dimension
example:
example:
in :
in :
...
@@ -28,24 +29,22 @@ class XmlaExecuteTools():
...
@@ -28,24 +29,22 @@ class XmlaExecuteTools():
out :
out :
{
'Geography':
'Geography':
+-------------+----------+---------+
+-------------+----------+---------+
| Continent | Country | Amount |
| Continent | Country | Amount |
+=============+==========+=========+
+=============+==========+=========+
| America | US | 35150 |
| America | US | 35150 |
+-------------+----------+---------+
+-------------+----------+---------+
,
'Product':
+----------+---------+---------+
'Product':
| Company |Article | Amount |
+==========+=========+=========+
| MS |Crazy De | 35150 |
+----------+---------+---------+
}
+----------+---------+---------+
| Company |Article | Amount |
+==========+=========+=========+
| MS |Crazy De | 35150 |
+----------+---------+---------+
:param mdx_execution_result: MdxEngine.execute_mdx() result
:param mdx_execution_result: MdxEngine.execute_mdx() result
...
...
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