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
bdf28b68
Commit
bdf28b68
authored
Jun 15, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change charging xmla config cubes V1
parent
b57be0cb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
15 deletions
+77
-15
cubes_templates/cubes_temp.zip
cubes_templates/cubes_temp.zip
+0
-0
olapy/core/mdx/executor/execute.py
olapy/core/mdx/executor/execute.py
+1
-1
olapy/core/mdx/executor/execute_config_file.py
olapy/core/mdx/executor/execute_config_file.py
+72
-12
olapy/core/services/xmla_discover_tools.py
olapy/core/services/xmla_discover_tools.py
+4
-2
No files found.
cubes_templates/cubes_temp.zip
View file @
bdf28b68
No preview for this file type
olapy/core/mdx/executor/execute.py
View file @
bdf28b68
...
...
@@ -67,8 +67,8 @@ class MdxEngine:
self
.
client
=
client_type
self
.
tables_loaded
=
self
.
load_tables
()
# all measures
self
.
load_star_schema_dataframe
=
self
.
get_star_schema_dataframe
()
self
.
measures
=
self
.
get_measures
()
self
.
load_star_schema_dataframe
=
self
.
get_star_schema_dataframe
()
self
.
tables_names
=
self
.
_get_tables_name
()
# default measure is the first one
self
.
selected_measures
=
[
self
.
measures
[
0
]]
...
...
olapy/core/mdx/executor/execute_config_file.py
View file @
bdf28b68
...
...
@@ -20,23 +20,31 @@ def _load_table_config_file(executer_instance, cube_obj):
db
=
MyDB
(
db
=
executer_instance
.
cube
)
memory_usage
(
"1 - before executing query //// _load_table_config_file"
)
for
table
in
cube_obj
.
dimensions
:
for
dimension
in
cube_obj
.
dimensions
:
value
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
table
.
name
),
# only certain columns
if
dimension
.
columns
.
keys
():
df
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
dimension
.
name
),
db
.
engine
)[
dimension
.
columns
.
keys
()]
else
:
df
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
dimension
.
name
),
db
.
engine
)
tables
[
table
.
name
]
=
value
[[
col
for
col
in
value
.
columns
if
col
.
lower
()[
-
3
:]
!=
'_id'
if
dimension
.
displayName
:
table_name
=
dimension
.
displayName
else
:
table_name
=
dimension
.
name
# rename columns if value not None
df
.
rename
(
columns
=
(
dict
((
k
,
v
)
for
k
,
v
in
dimension
.
columns
.
items
()
if
v
)),
inplace
=
True
)
tables
[
table_name
]
=
df
[[
col
for
col
in
df
.
columns
if
col
.
lower
()[
-
2
:]
!=
'id'
]]
memory_usage
(
"2 - after query, before fetchall /////// _load_table_config_file"
)
# update table display name
for
dimension
in
cube_obj
.
dimensions
:
if
dimension
.
displayName
and
dimension
.
name
and
dimension
.
displayName
!=
dimension
.
name
:
tables
[
dimension
.
displayName
]
=
tables
[
dimension
.
name
][
dimension
.
columns
.
keys
()]
executer_instance
.
dimension_display_name
.
append
(
table_name
)
executer_instance
.
dimension_display_name
.
append
(
dimension
.
name
)
memory_usage
(
"2 - after query, before fetchall /////// _load_table_config_file"
)
return
tables
...
...
@@ -53,6 +61,58 @@ def _construct_star_schema_config_file(executer_instance, cubes_obj):
db
=
MyDB
(
db
=
executer_instance
.
cube
)
# load facts table
memory_usage
(
"1 - before executing query //// _construct_star_schema_config_file"
)
fusion
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
executer_instance
.
facts
),
db
.
engine
)
for
fact_key
,
dimension_and_key
in
cubes_obj
.
facts
[
0
].
keys
.
items
():
df
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
dimension_and_key
.
split
(
'.'
)[
0
]),
db
.
engine
)
for
dimension
in
cubes_obj
.
dimensions
:
if
dimension_and_key
.
split
(
'.'
)[
0
]
==
dimension
.
name
:
df
.
rename
(
columns
=
dimension
.
columns
,
inplace
=
True
)
# todo test with this
fusion
=
fusion
.
merge
(
df
,
left_on
=
fact_key
,
right_on
=
dimension_and_key
.
split
(
'.'
)[
1
])
# fusion = fusion.merge(
# df, left_on=fact_key, right_on=dimension_and_key.split('.')[1], how='left',
# # remove suffixe from dimension and keep the same column name for facts
# suffixes=('', '_y'))
memory_usage
(
"2 - after query, before fetchall /////// _construct_star_schema_config_file"
)
# TODO CHOSE BETWEEN THOSES DF
# if separated dimensions
# fusion = fusion.merge(df, left_on=fact_key,right_on=dimension_and_key.split('.')[1])
# TODO CHOSE BETWEEN THOSES DF
# if facts contains all dimensions
# fusion = facts
# measures in config-file only
if
cubes_obj
.
facts
[
0
].
measures
:
executer_instance
.
measures
=
cubes_obj
.
facts
[
0
].
measures
return
fusion
def
_construct_star_schema_config_file_OLD
(
executer_instance
,
cubes_obj
):
"""
Construct star schema DataFrame from configuration file.
:param cube_name: cube name (or database name)
:param cubes_obj: cubes object
:return: star schema DataFrame
"""
executer_instance
.
facts
=
cubes_obj
.
facts
[
0
].
table_name
db
=
MyDB
(
db
=
executer_instance
.
cube
)
# load facts table
memory_usage
(
"1 - before executing query //// _construct_star_schema_config_file"
)
fusion
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
executer_instance
.
facts
),
db
.
engine
)
...
...
olapy/core/services/xmla_discover_tools.py
View file @
bdf28b68
...
...
@@ -1830,8 +1830,10 @@ class XmlaDiscoverTools():
# TODO in another idea, change this
# TO CHANGE NAME DISPLAY THAT EXISTS IN CONFIG FILE
if
MdxEngine
.
dimension_display_name
!=
[]
and
tables
in
MdxEngine
.
dimension_display_name
:
continue
# if MdxEngine.dimension_display_name != [] and tables in MdxEngine.dimension_display_name:
# continue
rows
+=
"""
<row>
<CATALOG_NAME>{0}</CATALOG_NAME>
...
...
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