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
9eaa424a
Commit
9eaa424a
authored
Jul 24, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format
parent
d3571181
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
80 deletions
+143
-80
olapy/core/services/xmla_execute_tools.py
olapy/core/services/xmla_execute_tools.py
+143
-80
No files found.
olapy/core/services/xmla_execute_tools.py
View file @
9eaa424a
...
...
@@ -138,7 +138,8 @@ class XmlaExecuteTools():
if
tupls
[
0
][
1
]
in
self
.
executer
.
measures
and
len
(
self
.
executer
.
selected_measures
)
>
1
:
with
xml
.
Member
(
Hierarchy
=
"[Measures]"
):
xml
.
UName
(
'[Measures].[{0}]'
.
format
(
tupls
[
0
][
1
]))
xml
.
UName
(
'[Measures].[{0}]'
.
format
(
tupls
[
0
][
1
]))
xml
.
Caption
(
'{0}'
.
format
(
tupls
[
0
][
1
]))
xml
.
LName
(
'[Measures]'
)
xml
.
LNum
(
'0'
)
...
...
@@ -149,7 +150,8 @@ class XmlaExecuteTools():
continue
for
tupl
in
tupls
:
tuple_without_minus_1
=
self
.
get_tuple_without_nan
(
tupl
)
tuple_without_minus_1
=
self
.
get_tuple_without_nan
(
tupl
)
# french caracteres
# TODO encode dataframe
...
...
@@ -160,33 +162,48 @@ class XmlaExecuteTools():
]
# todo ugly !!
with
xml
.
Member
(
Hierarchy
=
"[{0}].[{0}]"
.
format
(
tuple_without_minus_1
[
0
])):
xml
.
UName
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
tuple_without_minus_1
[
0
],
splited_df
[
tuple_without_minus_1
[
0
]].
columns
[
len
(
tuple_without_minus_1
)
-
first_att
],
'.'
.
join
([
'['
+
str
(
i
)
+
']'
for
i
in
with
xml
.
Member
(
Hierarchy
=
"[{0}].[{0}]"
.
format
(
tuple_without_minus_1
[
0
])):
xml
.
UName
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
tuple_without_minus_1
[
0
],
splited_df
[
tuple_without_minus_1
[
0
]].
columns
[
len
(
tuple_without_minus_1
)
-
first_att
],
'.'
.
join
([
'['
+
str
(
i
)
+
']'
for
i
in
tuple_without_minus_1
[
first_att
-
1
:]
])))
xml
.
Caption
(
'{0}'
.
format
(
tuple_without_minus_1
[
-
1
]))
xml
.
Caption
(
'{0}'
.
format
(
tuple_without_minus_1
[
-
1
]))
xml
.
LName
(
'[{0}].[{0}].[{1}]'
.
format
(
tuple_without_minus_1
[
0
],
splited_df
[
tuple_without_minus_1
[
0
]].
columns
[
len
(
tuple_without_minus_1
)
-
first_att
]))
xml
.
LNum
(
'{0}'
.
format
(
len
(
tuple_without_minus_1
)
-
first_att
))
tuple_without_minus_1
[
0
],
splited_df
[
tuple_without_minus_1
[
0
]].
columns
[
len
(
tuple_without_minus_1
)
-
first_att
]))
xml
.
LNum
(
'{0}'
.
format
(
len
(
tuple_without_minus_1
)
-
first_att
))
xml
.
DisplayInfo
(
'131076'
)
# PARENT_UNIQUE_NAME must be before HIERARCHY_UNIQUE_NAME (todo change it in xsd)
if
len
(
tuple_without_minus_1
[
first_att
-
1
:])
>
1
:
xml
.
PARENT_UNIQUE_NAME
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
if
len
(
tuple_without_minus_1
[
first_att
-
1
:])
>
1
:
xml
.
PARENT_UNIQUE_NAME
(
'[{0}].[{0}].[{1}].{2}'
.
format
(
tuple_without_minus_1
[
0
],
splited_df
[
tuple_without_minus_1
[
0
]].
columns
[
0
],
'.'
.
join
([
splited_df
[
tuple_without_minus_1
[
0
]]
.
columns
[
0
],
'.'
.
join
([
'['
+
str
(
i
)
+
']'
for
i
in
tuple_without_minus_1
[
first_att
-
1
:
-
1
]
for
i
in
tuple_without_minus_1
[
first_att
-
1
:
-
1
]
])))
xml
.
HIERARCHY_UNIQUE_NAME
(
'[{0}].[{0}]'
.
format
(
tuple_without_minus_1
[
0
]))
xml
.
HIERARCHY_UNIQUE_NAME
(
'[{0}].[{0}]'
.
format
(
tuple_without_minus_1
[
0
]))
return
str
(
xml
)
...
...
@@ -325,7 +342,7 @@ class XmlaExecuteTools():
if
np
.
isnan
(
value
):
value
=
''
with
xml
.
Cell
(
CellOrdinal
=
str
(
index
)):
xml
.
Value
(
str
(
value
),
**
{
'xsi:type'
:
'xsi:long'
})
xml
.
Value
(
str
(
value
),
**
{
'xsi:type'
:
'xsi:long'
})
index
+=
1
return
str
(
xml
)
...
...
@@ -382,19 +399,30 @@ class XmlaExecuteTools():
to_write
=
"[{0}].[{0}]"
.
format
(
dim_diff
)
if
dim_diff
==
'Measures'
:
# if measures > 1 we don't have to write measure
if
self
.
executer
.
facts
in
mdx_execution_result
[
'columns_desc'
][
'all'
]
and
len
(
mdx_execution_result
[
'columns_desc'
][
if
self
.
executer
.
facts
in
mdx_execution_result
[
'columns_desc'
][
'all'
]
and
len
(
mdx_execution_result
[
'columns_desc'
][
'all'
][
self
.
executer
.
facts
])
>
1
:
continue
else
:
to_write
=
"[Measures]"
with
xml
.
HierarchyInfo
(
name
=
to_write
):
xml
.
UName
(
name
=
"{0}.[MEMBER_UNIQUE_NAME]"
.
format
(
to_write
),
**
{
'type'
:
'xs:string'
})
xml
.
Caption
(
name
=
"{0}.[MEMBER_CAPTION]"
.
format
(
to_write
),
**
{
'type'
:
'xs:string'
})
xml
.
LName
(
name
=
"{0}.[LEVEL_UNIQUE_NAME]"
.
format
(
to_write
),
**
{
'type'
:
'xs:string'
})
xml
.
LNum
(
name
=
"{0}.[LEVEL_NUMBER]"
.
format
(
to_write
),
**
{
'type'
:
'xs:int'
})
xml
.
DisplayInfo
(
name
=
"{0}.[DISPLAY_INFO]"
.
format
(
to_write
),
**
{
'type'
:
'xs:unsignedInt'
})
xml
.
UName
(
name
=
"{0}.[MEMBER_UNIQUE_NAME]"
.
format
(
to_write
),
**
{
'type'
:
'xs:string'
})
xml
.
Caption
(
name
=
"{0}.[MEMBER_CAPTION]"
.
format
(
to_write
),
**
{
'type'
:
'xs:string'
})
xml
.
LName
(
name
=
"{0}.[LEVEL_UNIQUE_NAME]"
.
format
(
to_write
),
**
{
'type'
:
'xs:string'
})
xml
.
LNum
(
name
=
"{0}.[LEVEL_NUMBER]"
.
format
(
to_write
),
**
{
'type'
:
'xs:int'
})
xml
.
DisplayInfo
(
name
=
"{0}.[DISPLAY_INFO]"
.
format
(
to_write
),
**
{
'type'
:
'xs:unsignedInt'
})
return
str
(
xml
)
...
...
@@ -442,30 +470,62 @@ class XmlaExecuteTools():
if
axis_tables
:
with
xml
.
AxisInfo
(
name
=
Axis
):
# many measures , then write this on the top
if
self
.
executer
.
facts
in
axis_tables
.
keys
()
and
len
(
axis_tables
[
self
.
executer
.
facts
])
>
1
:
if
self
.
executer
.
facts
in
axis_tables
.
keys
()
and
len
(
axis_tables
[
self
.
executer
.
facts
])
>
1
:
with
xml
.
HierarchyInfo
(
name
=
'[Measures]'
):
xml
.
UName
(
name
=
"[Measures].[MEMBER_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
xml
.
Caption
(
name
=
"[Measures].[MEMBER_CAPTION]"
,
**
{
'type'
:
'xs:string'
})
xml
.
LName
(
name
=
"[Measures].[LEVEL_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
xml
.
LNum
(
name
=
"[Measures].[LEVEL_NUMBER]"
,
**
{
'type'
:
'xs:int'
})
xml
.
DisplayInfo
(
name
=
"[Measures].[DISPLAY_INFO]"
,
**
{
'type'
:
'xs:unsignedInt'
})
xml
.
PARENT_UNIQUE_NAME
(
name
=
"[Measures].[PARENT_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
xml
.
HIERARCHY_UNIQUE_NAME
(
name
=
"[Measures].[HIERARCHY_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
xml
.
UName
(
name
=
"[Measures].[MEMBER_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
xml
.
Caption
(
name
=
"[Measures].[MEMBER_CAPTION]"
,
**
{
'type'
:
'xs:string'
})
xml
.
LName
(
name
=
"[Measures].[LEVEL_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
xml
.
LNum
(
name
=
"[Measures].[LEVEL_NUMBER]"
,
**
{
'type'
:
'xs:int'
})
xml
.
DisplayInfo
(
name
=
"[Measures].[DISPLAY_INFO]"
,
**
{
'type'
:
'xs:unsignedInt'
})
xml
.
PARENT_UNIQUE_NAME
(
name
=
"[Measures].[PARENT_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
xml
.
HIERARCHY_UNIQUE_NAME
(
name
=
"[Measures].[HIERARCHY_UNIQUE_NAME]"
,
**
{
'type'
:
'xs:string'
})
for
table_name
in
axis_tables
:
if
table_name
!=
self
.
executer
.
facts
:
with
xml
.
HierarchyInfo
(
name
=
'[{0}].[{0}]'
.
format
(
table_name
)):
xml
.
UName
(
name
=
"[{0}].[{0}].[MEMBER_UNIQUE_NAME]"
.
format
(
table_name
),
with
xml
.
HierarchyInfo
(
name
=
'[{0}].[{0}]'
.
format
(
table_name
)):
xml
.
UName
(
name
=
"[{0}].[{0}].[MEMBER_UNIQUE_NAME]"
.
format
(
table_name
),
**
{
'type'
:
'xs:string'
})
xml
.
Caption
(
name
=
"[{0}].[{0}].[MEMBER_CAPTION]"
.
format
(
table_name
),
**
{
'type'
:
'xs:string'
})
xml
.
Caption
(
name
=
"[{0}].[{0}].[MEMBER_CAPTION]"
.
format
(
table_name
),
**
{
'type'
:
'xs:string'
})
xml
.
LName
(
name
=
"[{0}].[{0}].[LEVEL_UNIQUE_NAME]"
.
format
(
table_name
),
xml
.
LName
(
name
=
"[{0}].[{0}].[LEVEL_UNIQUE_NAME]"
.
format
(
table_name
),
**
{
'type'
:
'xs:string'
})
xml
.
LNum
(
name
=
"[{0}].[{0}].[LEVEL_NUMBER]"
.
format
(
table_name
),
**
{
'type'
:
'xs:int'
})
xml
.
DisplayInfo
(
name
=
"[{0}].[{0}].[DISPLAY_INFO]"
.
format
(
table_name
),
xml
.
LNum
(
name
=
"[{0}].[{0}].[LEVEL_NUMBER]"
.
format
(
table_name
),
**
{
'type'
:
'xs:int'
})
xml
.
DisplayInfo
(
name
=
"[{0}].[{0}].[DISPLAY_INFO]"
.
format
(
table_name
),
**
{
'type'
:
'xs:unsignedInt'
})
xml
.
PARENT_UNIQUE_NAME
(
name
=
"[{0}].[{0}].[PARENT_UNIQUE_NAME]"
.
format
(
table_name
),
xml
.
PARENT_UNIQUE_NAME
(
name
=
"[{0}].[{0}].[PARENT_UNIQUE_NAME]"
.
format
(
table_name
),
**
{
'type'
:
'xs:string'
})
xml
.
HIERARCHY_UNIQUE_NAME
(
name
=
"[{0}].[{0}].[HIERARCHY_UNIQUE_NAME]"
.
format
(
table_name
),
xml
.
HIERARCHY_UNIQUE_NAME
(
name
=
"[{0}].[{0}].[HIERARCHY_UNIQUE_NAME]"
.
format
(
table_name
),
**
{
'type'
:
'xs:string'
})
return
str
(
xml
)
...
...
@@ -535,10 +595,9 @@ class XmlaExecuteTools():
tuple
=
""
# not used dimensions
unused_dimensions
=
list
(
set
(
self
.
executer
.
get_all_tables_names
(
ignore_fact
=
True
))
-
set
(
table_name
for
table_name
in
mdx_execution_result
[
'columns_desc'
][
'all'
]))
set
(
self
.
executer
.
get_all_tables_names
(
ignore_fact
=
True
))
-
set
(
table_name
for
table_name
in
mdx_execution_result
[
'columns_desc'
][
'all'
]))
xml
=
xmlwitch
.
Builder
()
if
unused_dimensions
:
with
xml
.
Axis
(
name
=
"SlicerAxis"
):
...
...
@@ -548,31 +607,35 @@ class XmlaExecuteTools():
# TODO encode dataframe
# french caracteres
if
type
(
self
.
executer
.
tables_loaded
[
dim_diff
].
iloc
[
0
][
0
])
==
unicode
:
column_attribut
=
self
.
executer
.
tables_loaded
[
dim_diff
].
iloc
[
0
][
0
].
encode
(
'utf-8'
,
'replace'
)
if
type
(
self
.
executer
.
tables_loaded
[
dim_diff
].
iloc
[
0
][
0
])
==
unicode
:
column_attribut
=
self
.
executer
.
tables_loaded
[
dim_diff
].
iloc
[
0
][
0
].
encode
(
'utf-8'
,
'replace'
)
else
:
column_attribut
=
self
.
executer
.
tables_loaded
[
dim_diff
].
iloc
[
0
][
0
]
with
xml
.
Member
(
Hierarchy
=
"[{0}].[{0}]"
.
format
(
dim_diff
)):
xml
.
UName
(
'[{0}].[{0}].[{1}].[{2}]'
.
format
(
dim_diff
,
self
.
executer
.
tables_loaded
[
dim_diff
].
columns
[
0
],
column_attribut
))
column_attribut
=
self
.
executer
.
tables_loaded
[
dim_diff
].
iloc
[
0
][
0
]
with
xml
.
Member
(
Hierarchy
=
"[{0}].[{0}]"
.
format
(
dim_diff
)):
xml
.
UName
(
'[{0}].[{0}].[{1}].[{2}]'
.
format
(
dim_diff
,
self
.
executer
.
tables_loaded
[
dim_diff
].
columns
[
0
],
column_attribut
))
xml
.
Caption
(
str
(
column_attribut
))
xml
.
LName
(
'[{0}].[{0}].[{1}]'
.
format
(
dim_diff
,
self
.
executer
.
tables_loaded
[
dim_diff
].
columns
[
0
]))
xml
.
LName
(
'[{0}].[{0}].[{1}]'
.
format
(
dim_diff
,
self
.
executer
.
tables_loaded
[
dim_diff
].
columns
[
0
]))
xml
.
LNum
(
'0'
)
xml
.
DisplayInfo
(
'2'
)
# if we have zero on one only measures used
if
len
(
self
.
executer
.
selected_measures
)
<=
1
:
with
xml
.
Member
(
Hierarchy
=
"[Measures]"
.
format
(
dim_diff
)):
xml
.
UName
(
'[Measures].[{0}]'
.
format
(
self
.
executer
.
measures
[
0
]))
xml
.
Caption
(
'{0}'
.
format
(
self
.
executer
.
measures
[
0
]))
with
xml
.
Member
(
Hierarchy
=
"[Measures]"
.
format
(
dim_diff
)):
xml
.
UName
(
'[Measures].[{0}]'
.
format
(
self
.
executer
.
measures
[
0
]))
xml
.
Caption
(
'{0}'
.
format
(
self
.
executer
.
measures
[
0
]))
xml
.
LName
(
'[Measures]'
)
xml
.
LNum
(
'0'
)
xml
.
DisplayInfo
(
'0'
)
...
...
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