Académique Documents
Professionnel Documents
Culture Documents
Measure Attribute
Definition A numeric value Used to describe a measure
Notes:
Attributes are used to filter or aggregate measures
Dimension
To analyse measures by grouping attributes together by dimension
e.g
Dimension 1 Dimension 2
Product Sales Org.
Product Key Sales Org Key
Product Name Sales Org Name
Product Category Country
Supplier Region
Star Schema
Consists of one fact table that references one or more dimesnion tables
Fact table contains facts or measures as well as keys used to relate to the dimension tables
Hierarchy
Is a structured representation
Used to navigate the entire set of members with more ease
Info Views in HANA
* Used to create a Virtual Data Model
Note:
* Full outer join can be used only in calc view in standard join and star join nodes
* In star join node, full outer join can be defined only on one dimension
calc. view and this view must appear last in the star join node
Referential Join
* Semantically an inner join
* It assumes that the left table always has a matching entry in right table
* It is an optimized or faster inner join
* It does not check the right table if no fields are requested from the right table
Note:
Since SPS11, referential join is supported in any types of joins in calc. views,
earlier it can be used only in Star Join Node
Text Join
* Used to join a text table to a master data table
* Acts as a left outer join and can be used with SAP tables where the language
column
(SPRAS) is present
* Enables HANA to handle the translation of attribute labels
* Depends on the session language of the user
Temporal Join
* Is to find matching records from two tables, based on a date
* Useful to manage time dependent attributes
* Temporal conditions can be added to the following join types and view types
Info View Node Join Type
Join Node
Calculation View Inner Join
Star Join Node
Inner Join
Analytical View Star Join Node
Referential Join
Star Join
* Is a node type rather than a join type
* Used to structure data in star schema
* Fact table/data source can be any type of input node
* Only dim calc. views are allowed as input nodes for dimensions
* Type of join between fact and dimension tables within a star join node
can be defined in the star join node
* The available joins are as follows;
> Referential join
> Inner Join
> Left Outer Join
> Right Outer Join
> Full Outer Join
> Text Join
Spatial Join
* Enables modelers to use the native spatial capabilities of HANA in grpahical modeling tool
Join Cardinality
* Defines how two tables joined together are related, in terms of matching rows
Union Vs Join
* Avoid joins as they are costly from computing standpoint
* Union node is preferred and provides much better performance
Calculated Attributes
* Calculations can be an arithmetic or just a character string manipulation
* Calculated columns support non-measure attributes as part of the calculation
* Nested calculated column is possible (one calc. column is based on another calc column)
Gregorian Fiscal
* Made up of years, days, months * Organized into fiscal years and periods
* Adjust granularity level to
hours., mins and secs * Can define several fiscal varaints
* M_TIME_DIMENSION_* tables * M_FISCAL_CALENDAR
* Located in _SYS_BI schema * Located in _SYS_BI schema
Hidden Columns
* Hide columns in Semantics node
* Hidden columns will not be exposed to client tools
* Only a column that is added to the output of the top node of a
calculation view can be defined as a Label Column
Dynamic Join
* For more complex scenarios where you want to present two diff measures side-by-side
* A Dynamic Join can be defined only with multi-column joins
Union Node
* If you want to combine multiple result sets with identical structures into one
result set, you can use a union node
* Mapping of source to target is required and will allow you to adapt structural differences
* A Union node is used to combine two or more data sets to a common set of columns.
Union Nodethe
* Optimize Pruning
execution of union node by specifying condition in the dedicated
table which is called as Pruning Configuration Table
Aggregation Node
* Have further control on aggregations in graphical calc. views
* Calculated columns can bee assigned to aggrgation nodes
* These calculations happens after aggregation
* Used to apply aggregate functions on to measures based on one or more attributes
* Is simillar to Group By Clause
* Supports MIN, MAX, SUM , COUNT, Average, Variance and Std Deviation
* Default aggregation is SUM
Keep Flag:
* Setting the Keep Flag property to true for an attribute forces the calculation
to be triggered at the relevant level of granularity
Transparent Filter
* Setting the column to Transparent Filter as True will elimnate the column in Grou By clause
Attribute Measure
* if removed just provides the sum * Offers more flexibility
Enhance Flexibility in CV
* Switching node types without loosing link to the data source/lower and upper nodes
* Replacing a Data Source without losing the output columns, calc. columns
* Insert an additional calculation node (or remove an existing one) without losing
the link between columns end-to-end.
* Extract Semantics -
* Propagate Semantics
* Preview O/P of an intermediate node
* Map I/P parameters b/w nodes
Data Lineage
* Enables you to track the origin of a column in a calculation scenario
* Identify the column that has been renamed
Attribute Views
* Data foundation in AT_view can contain one or several tables
* Joins between these tables are defined within the data foundation
* Data foundation can join more than 2 tables if need be
* Can define calc. attribute columns in data foundation
Analytic Views
* Data foundation can have one or several tables but measures can originate
from only one table
Join Behaviour
Fact table
Data Preview preference screen
State
S.No STATE SNAME
1 MI MICHIGAN
2 AL ALABAMA
Sales Order Value
1 1000
2 200
3 300
4 109
5 18
6 10
7 12
Table 2
Region Product Value Region Total Sales
TN HT1000 1000 TN 3000
TN HT2000 2000 AP 5000
AP HT1000 2000
AP HT2000 3000
Tabi 1 Tab 2 op
Hierarchies
Level Hierarchies Plain hierarchy Heterogeneous fields With diff data types
* A level hierarchy requires each node in a separate column
** Heterogeneous
Is rigid in nature,fields
and the root and child nodes can only be accessed in a defined order.
Year
Quarter
Month
Week
Days
Parent-Child Hierarchy
1 step - To define the nodes making up the hierarchy
Multiple parents and compound parent-child definitions are not supported by MDX
Cycles
Not preferred
* "Enabling Time Depndency" check box supports Valid From and Valid To
* Source data should contain valid from and valid to columns
Enable for SQL Access in Calc View of type cube with star join
Option1 Enable for all shared hierarchies
Option2 Enable for the specified shared hierarchies
BI Client Tools that support Hierarchies
Restricted Columns
* Restrict to a subset of a column
* The restricted column is restricted based on one or more attributes
* The restriction cannot be based on a column defined as a Measure in the semantic
* A restricted column can be created in an aggregation node of a calculation view.
Calculated Columns
* You can define a calculated column as measure or attribute
* Ensure that you create the calculated column in a node prior to where aggregation
is performed.
* Minimize calculations before aggregation
Filters
* If client id is not mentioned in the user id then in calc view, no data is retrieved
* If client id is not mentioned in the user id then in analytic view, data from
all client is retrieved (cross client)
* $$CLIENT$$, system variable picks up the client value stored in user's id
Variable
* When using variable, a WHERE clause is added to the query
* Used to filter data at runtime
* Input either manually or from drop-down list
Single
Interval
Range
Input parameters
* Input parameters are compulsory for evaluation of an info model
* Reserve word PLACEHOLDER is used in SQL
Creating Variable
Variables
* Attribute selection is important for performance
* Variable can be used in expression of calculated columns, only single value
cannot be used in the expression
* Variables are created in Semantic nodes
* One variable can be assigned to multiple attributes
Input Parameters
* Input parameters to define internal parameterization of the view
* Direct Currency/UoM, reference tables are required
* Hierarchies can be passed as input variable
Note:
* Expression of calculated columns and expression of filters in projections
requires multi-value input
* Use Ïnput Enabled option"when passing input parameters of type
scalar function/procedure so that the user can modify the input
* Variables and input parameters support multiple default values since SPS10
* Input parameters can be called in calculated columns
Currency Conversion
* Possible both in graphical and Script
* SQLScript The function for currency conversion in SQLSCript is CONVERT_CURRENCY,
this based on column engine plan operators (CE functions)
* Since SPS12, currency conversion can be applied in any aggregation node of a calc. view
TCUR Schema
The Result currency column is never exposed to client tools. It is only available to
other SAP HANA views, where it can be used in additional calculations.
Decision Table
1. Condtions
2. Actions
Data Foundation
1. Tables
2. Info Models
3. Table Types
Parameters
Attributes
Calc. Attributes
Run time object of a Decision table is in _SYS_BIC (Schema) --> Procedures (Folder)
Condtions in the decision table are passed as input parameters to the procedure call
From SPS10 onwards, a Decision Table can be consumed in a Calculation View by referring to
the design-time object.
* In the data foundation of decision table, we can add the following data sources
> Dbase tables
> Analytic Views
> Cacl. Views
> Attribute Views
> Table Types
Need to check Restricted Column in system
Introducing SAP HANA SQL
SQL Console
* Used to type SQL statements and execute them
* Using SQL console is not recommended as;
> The statements are not saved anywhere, so we have to type statements in each system
> Requires auth. To execute stmts in Production or Test systems (Security Issues)
* Recommended is to use CDS
* CDS - No rework as codes can be ported from one system to another and no security issues
* SQL Console can be opened from system view in HANA Studio
* Has auto-completion feature (Ctrl+Space)
Notes:
-- is for commenting a single line
/* */ is to comment a group of lines
SQL Language Elements
Identifiers
Data Types:
* Used to specfiy the characteristics of data stored in Dbase.
Note: Null value indicates the absence of a value
Predicates
* Usually used in WHERE clause of a select statement
* Is specified by combining one or more expressions or logical operators and returns
one of the following logic or truth values;
> True
> False
> Unknown
LIKE Predicate
* Used for string comparisions
* Wildcard characters % or _ may be used in comparision
* % sign matches zero or more chars, _ sign matches exctly one char
* % or _ sign in LIKE predicate must use an escape character
Operators
* Use operators to perform operations in an expression
* Used for calculations, value comparision or to assign values
Functions
* Provides a reusable method to evaluate expressions and return info from dbase
Data type conversion functions
* Used to convert arguments from one data type to another
Number Functions
* Takes numeric values or strings with numeric chars as inputs and returns numeric values
* When strings with numeric chars are given as inputs, implicit conversion from
string to number is performed automatically before computing result value
Expressions
* Is a clause that can be evaluated to return values
Expression Type Description
Case Expressions IF ... THEN ... else logic without using procedures in SQL stmts
Function Expressions SQL built-in functions can be used as an expression
Aggregate Expressions
Uses an aggregate function to calculate a single value from the
values of multiple rows in a column (COUNT, MIN/MAX)
Subqueries in expressions SELECT statement enclosed in parentheses
Creating Tables
Syntax Elements
1. Table Type
2. Column Constraint
3. Table Elements
4. Column Definition
5. Data Type
Note: FOR UPDATE keyword locks the selected rows until end of transaction
Note:
* Union returns distinct values
* Union All returns duplicate values as well
Data Types
Imperative Logic
* Performance is not as same as declarative logic
EXEC Statement
* To create dynamic SQL statement
* Create SQL stmt at runtime in a procedure
* Dynamic SQL stmt;
> Opportunities for optimizations are limited
> Stmt is recomplied everytime the stmt is executed
> Cannot use SQLScript variables in SQL stmt
> Not possible to bind the result of a SQL stmt to SQLScript variable
> Injection bugs harms secuirty or integrity of dbase
> Recommended to avoid dynamic SQL
> Datasource is changed at rumtime
Securing Dynamic SQL
* Uses 3 built-in procedures;
> Single Escape Quotes
> Double Escape Quotes
> IS SQL Injection Safe
User Defined Functions (UDF)
2 ways to create
1. Create stmt in SQL Editor - pure run time object, no transport, not use in graphical calc view
2. Create design time object in package - Recommended, CDS doc with extension .hdbfunction
(scalar) and .hdbtablefunction (table)
Table Scalar
.hdbtablefunction .hdbfunction
Table Functions
Table Functions can be created only in Developer perspective
Table User Defined Functions allow an improved movement of filters from client tools down to
the source data.
* Design-time table functions are created in HANA devloper Perspective
Lesson 3 - Procedures
* Reusable processing block - Procedure
Procedures - Multiple input and multiple output/Can be of both scalar and table type
Procedure can call other procedure
Read only procedures can call read only procedures
Security Mode
Definer Invoker
Privlieges of _SYS_REPO user Privileges of the caller of the function
Note:
Analytic privileges are checked regardless of security mode
Procedures
* Each output variable of the procedure is represented as a result set.
Calling a Procedure:
* Procedure or table function can be called by a client on the outer most level, using any supported client interfaces
From HANA
artifact or weTutorial
create aBlog
reusable artifact containing this piece of code and call it wherever
needed.
INOKER/DEFINER in procedures?
There are 2 security modes:
INVOKER: the function executes with the privileges of the invoker of the procedure.
DEFINER:
It’s alwaysthe
bestfunction
to leaveexecutes with the
it as INVOKER privileges
so that of thethis
whenever definer of the
function procedure.
is called,
it will run based on the invoking user’s privileges.
Debug Perspective
* Includes a number of views to facilitate debugging
> Script Editor - set breakpoints, monitor status after execution. Edit, save the
script of your porcedure
> Debug View - Lists the procedures opened in debug session and their status
Note: You can suspend, resume, terminate and relaunch the debug thread
> Variables View - Display values of scalar and table variable types at each breakpoint
> Breakpoints View - Lists all breakpoints created. Allows to select/deselect
them before execution
Notes:
* Set breakpoints in SQL Script Editor View
* To add (or remove) a breakpoint, double-click the light-blue vertical bar on
the left of the SQLScript editor.
* The debugger needs to be granted the ATTACH DEBUGGER privilege by the owner.
The external debugger will see the same data as owner without being granted additional
system or analytic privileges
Lesson 5 - Deprecated SQL Modeling Objects
HANA Live
* Is for business suite
* Predefined data models based on SAP business suite tables
* Is of VDM
* Is not an RDS
* Is not an accelarator
* Has its own release cycle
* Focus on live operational reporting on business suite data
* HANA LIVE - Models
* RDS for HANA LIVE - BI reporting
* Fiori business applications based on the supplied VDM
* SAP BW is the recommended solution for Scalable Enterprise Data Warehouse (EDW)
Two Deployment options
1. Side by side scenario (side car) 2. Integrated Scenario (Suite on HANA)
* Requires data loading tool
* SLT is recommended
Architecture
** HANA live browser
Pre-delivered meta isdata
an XS
to layer application
*run the Browsertables to store
Pre-delivered
personalization data
* In order to access the live browser one or both of the of the versions
should be assigned to user role
Guidelines
Hiding Attributes
Note: set the flag, Execute in SQL engine for best performance
* Extension Assistant only works on std. SAP HANA Live views, not customer created views
Text Processing
Note:
Fuzzy search queries are handled by search engine
Linguistic processing is handled by Text Processor
UI Toolkit
* Provides UI building blocks
* Used to develop search apps
* Toolkit is based on HTM5 and JavaScript
* In case of full-text search, CDS docs contain syntax to create the following;
> Full-Text Indexes
> Search models via ODATA
Define Full-Text index in CDS --> Define search view in CDS --> Full text searching in integration
(ODATA, API)
The SlnA API is a client-side JavaScript API for developing browser-based search User Interfaces SinA - Simple Info Access
HANA File Loader
* Set of HTTP services to develop your own apps to search in file contents
* File loader is located within XS engine
* Supports the loading of file contents for search
* Used to load binary files into HANA
Executing Query
* HANA provides server-side JavaScript interface for text mining engine
* Data should be in column table
* Enable full-text index on column table
* Turn on Text mining
Note: getrelatedterms, getrelateddocuments
SQL Extensions for Text Mining
* Hana provides SQL functions to retrieve text mining statistics & enable data categrization
Full text index are automatically created during table creation for TEXT,
BINTEXT and SHORTEXT data types for the rest we have to create it manually
Full-Text Index
* Search includes; normalization, tokenization, word-stemming, part-of speech tagging
Note:
* Fuzzy search works out-of-the-box on the following column store data types;
> Text
> Short Text
> Varchar
> Nvarchar
> Date
To check paramteres for an existing full text index, you can query the monitoring view sys.fulltext_indexes
Note:
In-order to enable fuzzy text index, full-text index should be created first
* To use HANA studio for Search modeling, enable Search Options in Preferences
* Search attributes are not supported in graphical calc. views
Note: Use Freestyle search to perform search for a string across mulitple columns
* Geo queries are handled by spatial engine which is a part of cal. Engine
* Calc. engine is embedded in Index Server
* Spatial Clustering groups a set of points, that meets a certain criteria into clusters
Geocoding Features
* Geocoding will be provided by an external provider and Outbound connectivity is provided by XS
Decision Tree
Is one type of predicitive models
* A decision tree produces an outcome based on input variables.
* Need to be trained first before deployment
Vertices are stored in column tables and they represent the nodes in a graph
* In each vertex we can store multiple attributes
* Edges are stored in column tables and describes the line between members
* Vertices identifies the nodes
* Edges identifies the relationships between the nodes
* Possible to have multiple edges between two vertices
* Edges can be bi-directional and is between the vertices
* Tables of vertices and edges does not need to reside on the same schema
* Graph workspace contains the metadata
* Activated workspace resides in the system table SYS.GRAPH_WORKSPACES
Note:
When you execute the validation of information with one or several validation rules
disabled, you never get the job status, Completed Successfully.
If the validation actually succeeded, the job status is Completed with Warning, to
remind you that one or several rules were disabled during validation
Note:
Validation Log provides all the rules that generated error or warning.
Validation Log provides the rules that were not checked based on the settings
Auto Documentation
* Generate doc. Automatically on an info. Model
* Doc. Provides a list of all objects contained in a package & detailed design of each model
* Each info model gets its own Auto Doc. File (pdf)
* To generate - right click on an info model or directly the button
Note:
Only info model from package is included in auto doc. Not all contents in a package
Output consists of one or several pdf files
Included Excluded
* Attribute View * Procedures
* Analytic View * Decision Tables
* Calculation View * Analytic Privileges
Schema Mapping
* A schema is used in SAP HANA to group database objects, such as Tables, Views, or
Procedures.
* Define schema mapping before transporting models from one system to another
Creating a Schema
* Use Create Schema SQL statement in HANA Studio
* Schema created and named for each user when the user id is first created
Note:
* Requires to grant SELECT privileges to user _SYS_REPO in order to activate imoprted objects
Switch Ownership
* An inactive object of another user can be taken over by you using the "Takeover" feature
* Takeover enables you to become the owner of the inactive object
* Active version of the info. Model is owned by the last user who has activated it
* Use "Switch Ownership" command to modify the ownership of several objects
owned by the same user on one single operation
Notes:
* Switch Ownership allows you to takeover an inactive object that was never activated
* An info. View that was never active is visible only to its owner, so another user
cannot open it from system view
Note:
* The following should be active in-order to translate the metadata of a view;
> Translate property of the view in the semantics node
> Information view
Note:
* After migration, the workspace contains 2 inactive versions of the object
1. The former attribute or analytic view
2. The new calculation view
Migration Log
* Records the main changes
* Info provided by migration log
> Total no. of objects selected for migration
> Total no. of objects successfully converted
> List of objects that require user action before activation
> List of impacted objects
Secure Migration
Key recommendations for migration process
* Take a backup of all objects before executing the migration
* Start migration in a clean workspace with all views activated
* Simulate before migration
* Migrate info. Views before analytic privileges
* Undoing is only possible before activating the objects
check in system
check in system
Note:
Takeover and switch ownership in system
check in system
Unit 7 - Security in SAP HANA Modeling
Overview
Create Users
Assign Security - Control access to objects, Row-level security, restrict allowed actions
Manage Users
Defining Roles
Note:
Recommended - Repository roles
Repository Roles are created as .hdbrole files within the SAP HANA Developer
perspective. They cannot be created from the Modeler perspective.
Assign Privileges
Define Privileges
Types of privileges
Object privilege - on database objects
Analytical privilege - row level auth
Package privilege - Restrict access to and the use of packages Important for modelers
System privileges - admin tasks
Application privileges - for HANA native apps
System Privilege
* System based activities
* From modeler point - for maintaing, importing & exporting DU, creating, deleting schemas
Object Privilege
* Allow access to and modification of dbase objects
* Each object privilege is related to one object
* SQL statement types differ based on the object
* One user should have object privilege so as to grant access to another user
Package Privilege
* Allow access to and modification of info models in pacakages
* Actions on package: Read, Edit, Activate and Maintain
* Need package privilege to work on a package
* If you grant privileges to a user for a package, the user is automatically
also authorized for all corresponding subpackages
Analytic Privilege
* Is based on attribute value for all info views
* Must be defined and activated before being assigned to roles/users
* Can be assigned to info views
* Implemented for row level security
* Restrict acces to a data container based on attribute value
* Restricion supports, single value, range, and In List
* can be assigned to one or several attributes
* To be applied only on attributes but not on measures
* Multiple AP on single column is combined with AND
* Multiple AP on multiple column is combined with OR
* All filters except IS NULL and IS NOT NULL accept empty strings
* Only run time object can be assigned to user/roles
* _SYS_BI_CP_ALL is the built-in AP of HANA
* Detailed info of AP error can be found in trace file of Index server
SQL AP Classical AP
* More fleixibility where filter condition
are complex * Also called XML based AP
* Define attribute restrictions based on hierarchies * Historical data access restriction type
* Secure CDS views using SQL AP * Is deprecated
Privilege on users
* Used for debugging purposes
* Grant "Attach Debugger" to another user to allow them to debug an external session
Notes:
* HANA change recording is part of HANA Lifecycle management
* Roles that are specific to HANA Change Recording are as follows
• REPO.CONFIGURE
• REPO.MODIFY_CHANGE
• REPO. MODIFY_OWN_CONTRIBUTION
• REPO.MODIFY_FOREIGN_CONTRIBUTION
Object Privilege
There is no need to grant select privileges on the underlying views or tables. The
end user only needs to be granted select privileges on the top view of the view
hierarchy.
Analytic Privilege
* Row level filtering
* All underlying non-query views are explicitly excluded from analytic privilege
** Gen analytic
Analytic privilege
Privilege for ausing
queryAuthorization
view always Assistant tool based on PFCG auth
only one model
* In order to call these procedures you must be granted EXECUTE privilege on them
OLAP Engine:
* Used for calc and dimensional aggregations based on a star schema
* Is called from analytic and calc. view that is based uses a star join
Calculation Engine:
* Is used on top of OLAP engine and join engine
* For complex calculations
Spatial and Graph queries are processed by the their specific engines
Note:
In Views/Procedures/Functions
* Aggregate data records (e.g. Group By, reducing columns)
* Join on Keys Columns/indexed columns
* Avoid calc. before aggregation on line item level
* Replace sequential cursor looping with set processing
In Column Store
* Filter data amount asap in the lower layers
Explain Plan
* Generate Plan Explanation for any SQL stmt in SQL Console of HANA Studio
* Use to evaluate execution plan
* Helps to identify the engines used in the execution
* Avoid calling multiple engines
* Provides the essential visibility of the execution engines and the no. of times and
in the order they were called
Plan Visualize
* Helps to understand and analyze the detail of an execution plan of an SQL Stmt.
* Two modes of the tool
1. Prepare 2. Execute
* Prepares a data flow with an
estimated run time * Excutes the SQL and provides the
for all steps actual run time values
* Results are presented across 2 tabs;
Overview and Executed Plan
Timeline View
* Understand where the most time spent in the execution of your SQL
* Provides a complete overview of the execution plan based on the visualization
of sequential time-stamps
* Following infos are available
> X-axis - time elapsed since query execution
> Y axis - list of operators
> Duration of each operator is represented in rectangular box
> Nature of each time stamp
* Types of applications or scenarios that extend the capabilities of business processes in SAP
Business Suite systems by leveraging the performance & scalability advantages of SAP HANA.
* The typical approach for accelerators involves replicating data for data-intensive operations
for the given operation in an SAP HANA table.
* A type of “switch” is then set in the SAP Business Suite application to indicate that whenever
these specified tables are read, the read operation will take place in SAP HANA using a
"secondary database connection".