Beruflich Dokumente
Kultur Dokumente
modeling
SANSO TECHNOLOGIES
Revisit to Calculation Views
Create new tables in SAP HANA and fill them with data.
create schema <schema_name>;
----REPLACE <YOUR SCHEMA> WITH YOUR SCHEMA NAME
Product Table
Variables are bound to columns and are used for filtering using
WHERE clauses. As such, they can only contain the values available
in the Columns they relate to.
Sometimes you might not want a variable to just restrict the data of a
view. But you also want to take input from the user and process it,
returning dynamic data based on the user selection.
Input Parameters makes this possible.
Let us consider the same calculation view we created before which has
following attributes and measures.
• Attributes: PRODUCT_NAME, REGION_ID, REGION_NAME,
SUB_REGION_NAME
• Measures: SALES_AMOUNT
Suppose we want the end user to decide whether SALES_AMOUNT or
NET_AMOUNT should be shown in the output.
We can create a input parameter of type “Static List” which will have 2
values “SalesAmount” and “NetAmount”.
The calculation view will prompt for the input parameter. The user will
choose either “SalesAmount” or “NetAmount”. Based on this selection,
the output will be shown.
Important Features of Input
Parameters
• Input Parameters can contain any value the reporting user has to
enter to parameterize the result. Therefore, a data type must be
specified for each Input Parameter.
• Input Parameters are passed by Placeholders and used in
Formulas.
Input Parameter Types
WHERE:
The value of Variable is passed using WHERE clause.
WHERE ("REGION_NAME" IN ('Asia') )
Joins – Different Types of Joins in
SAP HANA
A Join clause combines records from two or more tables /view in a
database.
SAP HANA supports following types of join.
• Inner Join
• Left Outer Join
• Right Outer Join
• Full Outer Join
• Referential Join
• Text Join
We are going to use 2 tables to explain the different types of Join.
CUSTOMER and SALES_ORDER.
Customer Table
The INNER JOIN selects the set of records that match in both the
Tables.
Where to Use
The Left Outer Join selects the complete set of records from first
table (CUSTOMER), with the matching records (where available) in
second table (SALES_ORDER). If there is no match, the right side will
contain null.
Right Outer Join
The Right Outer Join selects the complete set of records from
second table (SALES_ORDER), with the matching records (where
available) in first table (CUSTOMER). If there is no match, the left side
will contain null.
Full Outer Join
The INNER JOIN selects the set of records that match in both the
Tables.
SAP HANA Referential Join
Referential join is performance wise better than inner join, but only
be used when you are sure that referential integrity is maintained.
SAP HANA Text Join
Purpose:
Create a calculation view which will give Product Name and
Product Description. The Product Description should be only in user's
session language.
Implementation:
Open HANA Studio. Right click on your schema and open SQL Editor.
Copy the below SQL script to create 2 tables - "PRODUCT" and
"PRODUCT_TEXT_TABLE".
Product Table
-- PRODUCT table
CREATE COLUMN TABLE "<YOUR_SCHEMA_NAME>"."PRODUCT"(
"PRODUCT_ID" INTEGER ,
"PRODUCT_NAME" VARCHAR(20) ,
primary key ("PRODUCT_ID"));
insert into "<YOUR_SCHEMA_NAME>"."PRODUCT" values(1,'Shirts');
insert into "<YOUR_SCHEMA_NAME>"."PRODUCT" values(2,'Jackets');
insert into "<YOUR_SCHEMA_NAME>"."PRODUCT" values(3,'Trousers');
insert into "<YOUR_SCHEMA_NAME>"."PRODUCT" values(4,'Coats');
insert into "<YOUR_SCHEMA_NAME>"."PRODUCT" values(5,'Purse');
Product Text
• Join Engine:
• Used when querying an Attribute View
• The join engine is also used, when you run plain SQL.
• OLAP Engine:
• Used for Analytic view (without calculated columns).
• Calculation Engine:
• Used for Analytic views with calculated attributes and Calculation views
Analytic Privileges – Overview and
Importance
Analytic privileges control access to SAP HANA data models.
Analytic privileges are used to grant different users access to
different portions of data in the same view depending on their
business role. It allows us to maintain row-level access.
Why do we need Analytic Privilege
While this is often sufficient, there are cases when access to data in
an object depends on certain values or combinations of values.
Analytic privileges are used in the SAP HANA database to provide
such fine-grained control of which data individual users can see
within the same view.
Suppose there is a calculation view which contains the sales data of
all the regions like Asia, Europe and America.
_SYS_BIC:
This schema contains all the columns views of activated objects. When the user activates the
Attribute View/Analytic View/Calculation View/Analytic Privilege /Procedure, the respective run-
time objects are created under _SYS_BIC/ Column Views.
_SYS_REPO:
Whatever the objects are there in the system is available in repository. This schema contains the
list of Activated objects, Inactive Objects, Package details and Runtime Objects information etc.
Also _SYS_REPO user must have SELECT privilege with grant option on the data schama.
_SYS_BI:
This schema stores all the metadata of created column Views. It contains the tables for created
Variables, Time Data (Fiscal, Gregorian), Schema Mapping and Content Mapping tables.
_SYS_STATISTICS:
This schema contains all the system configurations and parameters.
_SYS_XS:
This schema is used for SAP HANA Extended Application Services.
What happens when we activate
the modeling view
Whenever we create a modeling view (Attribute View, Analytic
View, and Calculation View) and activate it, the runtime column
views are created and stored under column view section of
_SYS_BIC schema.
The modeling view (for example a calculation view) cannot be
accessed directly. We need to call the corresponding column view
in _SYS_BIC.
Let us have a closer look.
• Right click on a modeling view and click on Data Preview. Go to Raw
tab to see the output.
Click on the Show Log Button on top right corner and copy the SQL
query.
Paste this SQL query in a SQL editor and let us analyze.
This is actually calling the corresponding runtime object (column
view) from _SYS_BIC schema.