Hi all. In this document I will be walking you through what is an attribute view and how to create the same.
What is an attribute view:
An attribute view can be regarded similar to master data/dimensions in SAP BW system. This can be joined with analytic
views to produce a star schema based structure. The same attribute view can be reused in multiple analytic and calculation views.
The following are types of Attribute View:
Here we will see how to create a standard attribute view.
Creation of Attribute View:
Before starting with creation of attribute view, the following are the required privileges/roles need to be assigned to your user:
- Access to schema from which your source tables are going to be fetched. If the source tables are present in your schema,
then you will be having full access by default.
- Modeling role.
- Select on your schema should be granted to _SYS_REPO user.
Log into SAP HANA system, and confirm whether you have all the above said Privileges/Roles and then
open SAP HANA Modeler perspective.
Right click on the package “Example” as shown below:
Select New -> Attribute View as shown below:
Enter the details the blow details in the dialog box that appears:
Label: ATTR_VIEW_01 (by default the value for label will be taken from the Name field). This can be left as it is.
Package: Example (This cannot be modified. The package name under which this attribute view is being created will be displayed here).
Subtype: Standard (There are various subtypes which we will see later, for now choose standard).
After keying in all the details click on “Finish” button to create the attribute view.
Note: We have not yet created the attribute view, but just the skeleton of it is created.
In the left pane, the layout of the attribute view can be seen. It is split into two parts:
- Data Foundation
The screen on right side pane will changed based upon what is selected in the left pane.
As the name implies, this is the foundation of this attribute view. A data foundation can contain multiple column tables.
Let us add the table “ARTICLE_COLOR_LOOKUP” which is present in schema “EFASHION_TUTORIAL”.
Drag the table ARTICLE_COLOR_LOOKUP and drop it into the “Data Foundation” box.
Once the table is dropped into data foundation, the below details will be displayed in the right side pane as shown.
Select field “ARTICLE_ID” to enable it in output of attribute view. Once “ARTICLE_ID” is selected the button near the field
will turn into Orange colour. Also the same can be seen in the output pane displayed under “Columns”.
Similar to ARTICLE_ID, select other required fields to be displayed in output of attribute view.
Go to “Semantics” node.
Here you can see what all fields are added to the output of attribute view, type of the field (here it is attribute which is symbolized
by the blue coloured trapezoidal icon). If any of the column is required not to be displayed in the output, but is required for
granularity of data, then the same column can be made as hidden by using the check box “Hidden” in the semantics node.
Select the tick icon highlighted in below screenshot “Validate and Save”.
The attribute view should now be saved and logs will be displayed.
Now select “Activate” button .
The attribute view should get activated. The same can be seen in the Job Log.
The above log will be displayed in red if the activation got failed.
Now let us check on the data that this attribute view can display. Click on the “Data Preview” button as shown below.
Select “Raw Data”. The data will be displayed in table format.
The tab “Analysis” will provide you with a graph overview:
Distinct values will give count of distinct value present in the selected attribute:
Let us add some more complexity to this attribute view by adding one more table “ARTICLE_LOOKUP” in the data foundation as below:
Select all the fields from the output and click remove to remove all the fields.
Select the fields “ARTICLE_ID” and “CATEGORY” from the table “ARTICLE_LOOKUP”
Select the node “ARTICLE_ID” from table “ARTICLE_LOOKUP” and join it with the field “ARTICLE_LOOKUP”
of table “ARTICLE_COLOR_LOOKUP”.
Note: In the attribute view the direction of Join decides which table is left table and which is right table. As we join ARTICLE_ID from table
ARTICLE_LOOKUP to ARTICLE_ID of table ARTICLE_COLOR_LOOKUP, the table ARTICLE_LOOKUP is left table and table
ARTICLE_COLOR_LOOKUP becomes the right table.
Choose the Join (link) between the two tables and check the properties pane. Here you can identify which table is selected as
left element and which is selected as right element. Also the default Join type is “Referential Join”.
Note: The direction in which you perform the join decides which is right and which is left table.
Referential join acts as inner join when in report fields from both tables are selected. If in report, field from only left table is selected,
this join acts as left outer join.
As join is always not performed in referential join its performance is better compared to an inner join.
We have also selected the field COLOR_CODE from table “ARTICLE_COLOR_LOOKUP”. So when we check data preview, for all values
of ARTICLE_ID present in table “ARTICLE_LOOKUP” the corresponding entries of “COLOR_CODE” is selected from table
Activate this attribute view, it will throw an error.
The error is that “No key attribute has been specified”. If you remember, we did not encounter any error while activating the attribute view with
a single table in data foundation. This is because, when there is only one table in data foundation, it is not mandatory to select an attribute as
key field. But when there are more than 1 table present in the data foundation, it is mandatory to select at least 1 field/attribute as key.
Select the field “ARTICLE_ID” from output pane and set its Key Attribute property to “TRUE” in the properties pane as shown below:
Now click on “Save and Activate”. Check the Job log, the activation is successful.
Now check data preview:
The selected fields alone are displayed in output.
The different tables present in data foundation can be joined with one another using the below Join types:
- Referential Join (default type)
- Inner Join
- Left Outer Join
- Right Outer Join
- Text Join (This is applicable only when you have a language field in text table, and is possible only within an attribute view)
Hope you all would find this document useful. Thanks.