doc-1216 sap hana modeling
Post on 19-Jan-2016
167 Views
Preview:
DESCRIPTION
TRANSCRIPT
SAP HANA Modeling Overview
SAP HANA Product Management November, 2013
SAP HANA Modeling Overview
© 2012 SAP AG. All rights reserved. 3 Public
SAP HANA Modeling Views - Overview
Data and Processing in SAP HANA
In-Memory Data Stores: Column- and Row Store
Optimized for Query and OLTP Workload
SQL & OLAP Processing and specific Calculation Operators
Application Function Library for specific Scenarios, e.g. Predictive Analytics
Modeling in SAP HANA
Information Models (SAP HANA Views) are optimized for SAP HANA Engines and Calculation Operators
Data/Columns are classified as Attributes or Measures in SAP HANA Views
Attributes – descriptive data (known as Characteristics SAP BW terminology)
Measures – data that can be quantified and calculated (known as key figures in SAP BW)
No materialized aggregates
Three levels of modeling: Attribute View > Analytic View > Calculation View
© 2012 SAP AG. All rights reserved. 4 Public
SAP HANA Modeling Views - Overview
Attribute Views
• Compose a dimensional view
with a series of attributes derived
from a collection of tables
e.g. Master Data Views
Highly re-used and shared in
Analytic- and Calculation Views
Used to build Hierarchies
Hierarchies are key elements in
use with Analytic View for multi-
dimensional reporting
Analytic Views
• Combines Fact-Tables with
Attribute-Views to Star-Schema-
or OLAP Cube-like objects for
multidimensional reporting.
• Stores no aggregates and mass-
aggregates on the fly
• Hierarchies are key for multi-
dimensional access (navigation,
filtering, slicing and aggregation)
Calculation View
• Great flexibility for advanced use
• Approach to model custom
scenarios like
Combined use of Multiple-Fact
Tables/Analytics Views
Build Models on Normalized Data
Re-Use and stack views
Make use of custom scripted views
© 2012 SAP AG. All rights reserved. 5 Public
SAP HANA Modeling Views - Multidimensional Model Scenario
Analytical View Attribute View Column Table
Calculation View
Reporting Tools can usually directly consume HANA Calculation Views or Analytic Views.
Multidimensional Tools support Hierarchies for Navigation, Filtering and Aggregation and HANA Prompts (Variables & Input Parameters) for efficient Pre-Filtering of Data.
Calculation Views are usually build upon Analytic-, Attribute- Views, and Column Tables
© 2012 SAP AG. All rights reserved. 6 Public
SAP HANA Modeling Views - Normalized Data Model Scenario
SAP HANA Calculation Views provide the means to model sophisticate views based on normalized data structures.
See SAP Note 1857202
Complex Calculation Views demand a more explicit intent and control of the modeled set-based data flow, i.e. slicing, aggregation and filtering of sets as input to joins, unions etc.
SAP HANA Calculation Views typically feed data to Business Applications, like SAP HANA XS build Applications
© 2012 SAP AG. All rights reserved. 7 Public
The SAP HANA Studio Model Editor
The Graphical Model Editor
Standardized graphical editing across
different SAP HANA view types
Build of different common panels
– Scenario provides Overview
– Semantic node provides better summary
of output structure of the model
+ editor view of output objects
+ general view properties
– Logical-Join- and Data Foundation-Nodes
are specific to Attribute- and Analytic Views
– Calculation-Views are modeled in the scenario panel
based on a palette of node-objects like join, union, etc.
to compose a custom data flow.
Model Scenario General View Properties, Semantic Information
Logical Join of Data Foundation & Dimensions
Data Foundation
SAP HANA Studio Modeling
Environment
© 2012 SAP AG. All rights reserved. 9 Public
SAP HANA Studio – Modeling Perspective
The SAP HANA Modeler within the SAP HANA studio
• Eclipse-perspective targeting Power Users for Content Design
• Graphical Information Model Design Environment
for HANA optimized Models
‒ Attribute-, Analytic- and Calculation Views
‒ without materialized aggregates
• Development of advanced
Calculation Models
‒ SQL & SQLScript-based,
Use of Application Function
Library- and SQLScript-based
Stored Procedures
© 2012 SAP AG. All rights reserved. 10 Public
SAP HANA Studio – Modeling Perspective
The SAP HANA Modeler Eclipse-perspective
Perspectives are build upon different View-Windows in the Eclipse environment
Perspectives
Typical View-Windows
© 2012 SAP AG. All rights reserved. 11 Public
SAP HANA Studio – Modeling Perspective
The SAP HANA Modeler within the SAP HANA studio
• Quick Launch access to common modeling tools
Wizards for creating / graphical designing HANA
Content objects as Information Models
Managing the work environment and system
connections
Actions or wizards for working with content
Actions or wizards for working with data or working with a SQL console
© 2012 SAP AG. All rights reserved. 12 Public
SAP HANA Studio – The HANA System Environment
The content contains the HANA Studio Models meta data, e.g. for Analytic Views, Attribute Views, Calculation Views. The content is organized in packages.
The catalog contains the HANA database schema and the stored objects, like column tables
From content tree and the package structure the Editor to build new HANA Views can be called
© 2012 SAP AG. All rights reserved. 13 Public
SAP HANA Studio – The Unified Model Editor
Unified Graphical Editor Standardized graphical editing across
different HANA Database view types
Build of different common panels
– Scenario provides Overview
– Semantic node provides better summary
of output structure of the model
+ editor view of output objects
+ general view properties
– Logical-Join- and Data Foundation-Nodes
are specific to Attribute- and Analytic Views
– Calculation-View* supports different nodes
Model Scenario General View Properties, Semantic Information
Logical Join of Data Foundation & Dimensions
Data Foundation
*New in SAP HANA SPS6
Getting Started with Modeling Modeling Attribute Views
Modeling Analytic Views
Modeling Calculation Views
© 2012 SAP AG. All rights reserved. 15 Public
Modeling Attribute Information – HANA Attribute Views
© SAP AG 2011
What is an Attribute View?
• ... are the reusable Dimensions Used for Analysis
which add context to data.
• Can be regarded as Master Data Views
Build a semantic attribute information collection
from various source tables (e.g. join ‘Plant’ to ‘Material’)
Can be re-used as dimensions in Analytical Views
Specific time-based Attribute Views are supported
Semantic Attribute Information
Attribute Data Foundation
© 2012 SAP AG. All rights reserved. 16 Public
Modeling Attribute Information – HANA Attribute Views
© SAP AG 2011
What are the capabilities of Attribute Views?
• Attribute Views supports
Description Mapping & Text-Join Lookup master data tables
e.g. used for handling of multi-language master data
Various joins types between data foundation tables
Time Dimension Attribute Views
Hierarchies (Level, Parent-Child)
Calculated Attributes (static or dynamic calculations)
Define filter values on column
…
© 2012 SAP AG. All rights reserved. 17 Public
Attribute View – Data Foundation
Building the Attribute Data Foundation
• An Standard Attribute View is a join of several tables
Referential, Inner, Left Outer, Right Outer and
Text Join
Text Join are used to join a text table to a master data
table to lookup language dependent texts like product
name
Filter (static or dynamic) on source object columns
The output structure of the view is explicitly defined
Calculated attributes added
© 2012 SAP AG. All rights reserved. 18 Public
Attribute View – Define View Semantics
Define Semantic Output Representation of Attributes
• Classify the Columns and Calculated Columns as attributes and key attributes
• Maintain General View Properties
Default Client, Enable Analytic Privileges
• Attributes can be specified as hidden,
if only used in calculated attributes
• For each output column a ‘label column’
can be specified, which points to another column
containing a description for the original column
• Define Attribute Hierarchies
Level Based and Parent-Child Hierarchies
© 2012 SAP AG. All rights reserved. 19 Public
Attribute View – Save, Activate and Preview
Create executable version of the view
• Save the view: Creates a Repository/Design-Time Object
This information model itself is not visible to reporting tools
• Activate the view: Creates a Catalog/Run-Time Object
This creates a database view in schema ‘_SYS_BIC’
(a so-called ‘column view’)
This column view can be accessed from reporting tools
• Data Preview
Getting Started with Modeling Modeling Attribute Views
Modeling Analytic Views
Modeling Calculation Views
© 2012 SAP AG. All rights reserved. 21 Public
Modeling Facts and Dimensions – OLAP Star Schemas
What is an OLAP Star Schema?
• Star schema usually has one fact table containing
the key figures
• Key figures are measureable
numbers
• Dimensions describe the key figures
and enrich them with additional information (usually
master data)
• Cardinality in star schemas is generally
N:1 fact to dimension
• Joins in star schemas are generally
Left Outer Joins
• Slicing and dicing is a feature whereby users can
take out (slicing) a specific set of data of the cube
and view (dicing) the slices from different
viewpoints.
HANA Analytic Views build and extend this concept of a
OLAP Star Schema Model
© 2012 SAP AG. All rights reserved. 22 Public
Modeling Facts and Dimensions – HANA Analytic Views
© SAP AG 2011
What is an Analytic View?
• Can be regarded as Cube-/OLAP Star Schema-like, but without storing aggregated data
Data is read from the joined database tables
Joins and calculated measures are evaluated at run time
• Fact Data from the ‘Data Foundation’ is joined against modeled Dimensions (Attribute Views)
fact table contain the key figures
‘Measures’
Dimensions describe the
key figures and enrich the data
HANA Analytical Views are
highly optimized
for aggregating mass data
Semantic Information
Logical Join of Data Foundation & Dimensions
© 2012 SAP AG. All rights reserved. 23 Public
Modeling Facts and Dimensions – HANA Analytic Views
© SAP AG 2011
What are the capabilities of Analytic Views?
• Defining Calculated & Restricted Measures
Aggregation (sum, max, ..)
Expressions / Operators / Functions
• Currency and Unit Conversion
• Variables and Input Parameters
Variables and Parameters are usually entered
manually by the users using UI Prompts
Note: Variables are bound to attributes and used to
filter using WHERE clauses (Single, Interval, Range).
© 2012 SAP AG. All rights reserved. 24 Public
Analytical View – Structural Overview
Semantics Information
• Classify the Columns and Calculated
Columns as attributes and measures.
You can also create variables/input
parameters, and assign variables to the
columns in the Semantics node.
Logical Join with Attribute View
• Join attribute views to these tables in the
Logical Join node.
Data Foundation of Fact Data
• Create a fact table by adding and joining
the tables
Semantic Information
Logical Join of Data Foundation & Dimensions
Data Foundation
© 2012 SAP AG. All rights reserved. 25 Public
Analytical View – Data Foundation
© SAP AG 2011
Building the Analytic View Data Foundation
• Fact Data is modeled in the ‘Data Foundation’ pane
Add source fact table(s), which contain the key figures ‘Measures’
Note: multiple tables can be joined, however measures may only be selected or derived from one of the table
Select attributes and measures from table(s) this defines the data foundation
Input Parameter can be defined
Filter on source object columns
• Can be based on any table column
• Column does not need to be selected
for output ([key] attribute)
• Input Parameters* are supported.
Data Foundation
*Since SPS6 Input Parameter references can be used (typed in) for filters on data foundation in Analytic and Attribute Views
© 2012 SAP AG. All rights reserved. 26 Public
Analytical View – Logical View
© SAP AG 2011
Building the Logical Analytic View
• Define joins between Attribute Views and Data Foundation
Typically Left Outer-, Inner-, Referential- or Temporal Joins
© 2012 SAP AG. All rights reserved. 27 Public
Analytical View – Logical View
© SAP AG 2011
Building the Logical Analytic View
• Creating Calculated Columns in the Logical View Output
Aggregation (sum, min, max, count), Counter (DistinctCounts)
Data Types (decimals, numbers etc.)
Expressions / Operators
Functions (String, Date Math, Conversion…)
• Advanced Semantic Calculations
Unit of Measure and Currency Conversion
• Creating Restricted Columns
Support constraints to apply for data used for
calculating the measures
• Creating Input Parameters
Prompted Parameter use e.g. in Calculation
and/or Filters
© 2012 SAP AG. All rights reserved. 28 Public
Analytical View – Define View Semantics
Define Semantic Output Representation of the Analytical View
Classify columns as attributes or measures Assign Variables to columns Create Measures Display Folders Order Columns, specify as hidden, select label columns, …
Create Variables and Input Parameters
Inspect Hierarchies from underlying Attribute Views
Set View Properties
© 2012 SAP AG. All rights reserved. 29 Public
Analytical View – Define View Semantics
Define Semantic Output Representation of the Analytical View
• Maintain General View Properties
Default Client, Enable Analytic Privileges
and further advance properties.
• Semantic Column Area
Filter Variables can be directly specified and
Variable Names specified with Filter-Information
For Multidimensional Reporting Clients,
Measure Display Folder can be defined to better
structure measures
Column Semantic-type can be specified and
full unit/currency conversion specifications
Calculated column definition reviewed
Where-used analysis of columns
© 2012 SAP AG. All rights reserved. 30 Public
Analytical View – Excursus Variable and Input Parameters
© SAP AG 2011
What are Variables and Input Parameters?
• Variables and Input Parameters
Variables and Parameters are usually entered
manually by the users using UI Prompts
Variables are bound to attributes and used to
filter using WHERE clauses
(Single, Interval, Range)
Input Parameters are passed by
Placeholders and used in Formulas (Attribute,
Currency, Date, Static List) & Filters
Variables can accelerate the joining of views
by reducing the data set before join occurs
SELECT
SUM(ORDER_QTY), COUNTRY
FROM
"_SYS_BIC"."eim260/SALES_DELIVERY_CV"
('PLACEHOLDER' = ('$$IP_COUNTRY$$', 'US'))
WHERE
("CREATED_ON" BETWEEN ('20120101') and ('20120501')) AND
("DELIVERY_DATE" BETWEEN ('20120101') and ('20120501'))
GROUP BY "COUNTRY"
Variables
Input Parameter
as Filter
if("COUNTRY"= '$$IP_COUNTRY$$',"GROSS_AMOUNT",0)
Input Parameter in Calculations
© 2012 SAP AG. All rights reserved. 31 Public
Analytical View – Excursus Variable and Input Parameters
© SAP AG 2011
Creating Variables
• Variables and Input Parameters
Revisited create variable dialog texts to be more self-explaining
Selected Attributes in Variables are automatically defaulted as applied
for the variable filter
Variables can be directly created from the details area of the semantic
node where the variable name is show along with the filter icon
External views or tables for value help dialogs can be referred to.
Special default values are now supported and can be authored via
an expression editor
– E.g. formulas as default like “date(Now())“ for today
© 2012 SAP AG. All rights reserved. 32 Public
Analytical View – Excursus Variable and Input Parameters
© SAP AG 2011
Creating Input Parameters
• Input Parameters
Special default values are now supported and can be authored via
an expression editor – E.g. formulas as default like “date(Now())“ for today
– Evaluated expression will be shown, e.g. for now-function the day will be displays
External views or tables for value help dialogs can be referred to
Semantic type for input parameter specifications
© 2012 SAP AG. All rights reserved. 33 Public
Analytical View - Save, Activate and Preview
Create an executable version of the analytical view and preview
• Save the view: Creates a Repository/Design-Time Object
• Activate the view: Creates a Catalog/Run-Time Object
• Call the preview , for which there are 3 modes available
Raw data (table display)
Number of distinct values per column
Interactive graphical analysis
Can create filters
Number of records is limited
(as specified in the
SAP HANA Studio preferences)
© 2012 SAP AG. All rights reserved. 34 Public
Analytical View - Save, Activate and Preview
Create an executable version of the analytical view and preview
• Save the view: Creates a Repository/Design-Time Object
• Activate the view: Creates a Catalog/Run-Time Object
• Call the preview , for which there are 3 modes available
Raw data (table display)
Number of distinct values per column
Interactive graphical analysis
Can create filters
Number of records is limited
(as specified in the
SAP HANA Studio preferences)
© 2012 SAP AG. All rights reserved. 35 Public
Activation creates a column view can be accessed from reports
Exposed like regular views via SQL/MDX interfaces
Analytical View - Run-time object: column view
© SAP AG 2011
Column Store
Activate
Reports
Getting Started with Modeling Modeling Attribute Views
Modeling Analytic Views
Modeling Calculation Views
© 2012 SAP AG. All rights reserved. 37 Public
Modeling Custom Scenarios – HANA Calculation Views
What is a Calculation Views?
• Calculation Views are composite views and can be used to combine other views
Can consume other Analytical-, Attribute-, other Calculation Views & tables
• Approach to model custom scenarios like
Combined use of Multiple-Fact Tables/Analytics Views
Build Models on Normalized Data
Re-Use and stack views
Make use of custom scripted views
• Great flexibility for advanced use
• Modeling Approaches: Graphical Modeler or
SQLScript-based Editor
Calculation View
Application UI
© 2012 SAP AG. All rights reserved. 38 Public
Modeling Custom Scenarios – HANA Calculation Views
What are the capabilities of Calculation Views?
• Graphical Calculation Views
Can consume other Analytical-, Attribute-, other Calculation Views & tables
Built-in Union, Join, Projection & Aggregation nodes
Besides flexibility provides additional features like
DistinctCount calcualtion, dynamic joins, ….
No SQL or SQL Script knowledge required
• SQLScript-based Calculation Views
Can be regarded as a function, defined in the HANA-specific
language “SQLScript”, which is build upon SQL commands
or special HANA pre-defined functions.
Must be read-only.
Analytical View
Calculation View
Attribute View
Column Table
Calculation View
© 2012 SAP AG. All rights reserved. 39 Public
Graphical Calculation View – Building the Scenario
Designing the Calculation View Scenario
Select View Type: Select Graphical or SQL Script
Select Output Type: should the CV’s final output set aggregate measures or rather produce a list-like output
without aggregating the measures.
– Enable Data Category “CUBE” aggregates measures, then the default (top output)-node is pre-selected as an
aggregation node (can be switched later) otherwise as an projection node
If Data Category is left ”<empty” • The output node does not offer any measures
but just attributes
• The Calculation view is not consumable via
Multidimensional Reporting Clients
• The Calculation view is only consumable via SQL
if Data Category is set to ”DIMENSION” • The output node does not offer any measures
but just attributes
• The Calculation view is to be used with CUBE-
StarJoin enabled calculation views.
© 2012 SAP AG. All rights reserved. 40 Public
Graphical Calculation View – Building the Scenario
Designing the Calculation View Scenario
Composing a calculation flow with nodes
– Projection, Aggregation, Join and Union-Nodes
can be drag’n dropped from tools palette into the scenario
and connected appropriate to demands
– Contributing objects to a node, are now
collapsed into the node
Adding table or view objects
– Select via drag’n drop from catalog or content
– search from repository & local project workspace
– Catalog Tables, Calc Views (Graphical, Scripted),
Attribute and Analytic views
– Drop elements into node placeholders directly or
connect later to nodes
© 2012 SAP AG. All rights reserved. 41 Public
Graphical Calculation View – Working with Nodes
Working with the Projection-Node in the Scenario
• Projection nodes can be added to add extra fields.
For example, setting the Actual versus Planned indicator
Drag a connection line between all the nodes
The output node will represent the data flow graph end
• Projection output set can be customized with
Renaming, Calculated Columns, Input Parameters,
Filters, ….
Projection node as an intermediate node in the calculation flow
© 2012 SAP AG. All rights reserved. 42 Public
Graphical Calculation View – Working with Nodes
Working with the Aggregation-Node in the Scenario
• In order to have further control of how the aggregation is done,
it is beneficial to use the aggregation node
in Graphical Calculation Views.
When using the aggregation node you can specify
which columns should be aggregated and
also the aggregation type (sum, min or max).
You can also add Calculated Columns to the node.
These calculations will be performed after aggregation.
Note: The definition of the specific aggregation type for calculated
columns is maintained in the property view.
Selecting Measures as aggregated output of the node
© 2012 SAP AG. All rights reserved. 43 Public
Graphical Calculation View – Working with Nodes
Working with the Join-Node in the Scenario
• Used to query data from two data sources,
which are joined by a specific criteria
Inner-, Left/Right-Outer, Text- and Dynamic Join
If more than two tables have to be joined, join-nodes
have to be used in a stacked-flow
Join properties can also be maintained in the properties view of the join details.
Join dialog window
© 2012 SAP AG. All rights reserved. 44 Public
Graphical Calculation View – Working with Nodes
Working with the Union-Node in the Scenario
• Union Operations
When multiple result sets should be combined by using
placing them on top of each other use the union-node
• Column Mapping in Unions
In order for the columns from the different sources
to go into the correct target, a mapping will need
to be provided.
This can be done via a drag and drop in the union
editor area or by using Auto Map by Name
in order to auto map columns by name between sources
and target
Define the UNION by mapping both Projection Nodes to the target
© 2012 SAP AG. All rights reserved. 45 Public
Graphical Calculation View – Working with Nodes
Working with the Union-Node in the Scenario
• Using constants in unions
When sources have a different number of columns,
a constant value can be set for the source columns that
do not have the target column and map the constant to the
target column
Allow to add unmapped columns that only have a
constant mapping (without a match to any source column)
• Setting constant values
The Constant Value can be set by right-clicking on the
Target column, selecting “Manage Mappings”.
Additionally it is required to specify a data type
If targets column don’t yet exist, e.g. for constant mapping, they can just be added in the union
Example: The Planned vs. Actual indicator can now be set in
the Union instead of defining the flag within a Projection node.
© 2012 SAP AG. All rights reserved. 46 Public
Graphical Calculation View – Working with Nodes
Best Practice for Joins and Unions
• Be careful and do not JOIN Analytical Views, this could lead to performance implications as Analytical
Views often expose mass data, where joins can be challenging
• Instead Unions may be used alternativels, as union do not compare records between right and left table.
Unions are simple set-combinings between these tables if the structure or the field mapping is identical.
Unions are used to combine the result-set of two or more SELECT statements
© 2012 SAP AG. All rights reserved. 47 Public
Graphical Calculation View – Define View Result Set
Define the structure of the Result Set of the Calculation View
• Calculation View Result Set
In the default node, a projection or
aggregation node, below the semantic
node, the output columns can be selected
from its input node
Add Attributes and Measures to the Output
Define Calculated Columns or Counters
Define Input Parameters
© 2012 SAP AG. All rights reserved. 48 Public
Graphical Calculation View – Define View Result Set
Define the structure of the Result Set of the Calculation View
• Creating Calculated Columns
Calculated columns in CV can combine data from multiple input
source and thus measures across different subject areas
Calculated Column Editor can be used to create Calc. Measure
and Attribute
© 2012 SAP AG. All rights reserved. 49 Public
Graphical Calculation View – Define View Result Set
Define the structure of the Result Set of the Calculation View
• Creating Calculated Columns and counters
• In the default (last/top node (projection or aggregation) special
calculated column can be defined
Special semantic measures: Amount with Currency and
Quantity with Unit of Measure
Counters: A counter is a distinct count of values from one or
multiple attribute columns Note: counters can only be defined in calculation views
© 2012 SAP AG. All rights reserved. 50 Public
Graphical Calculation View – Define View Semantics
Define Semantic Output Representation of the Calculation View
• Maintain General View Properties
Default Client, Enable Analytic Privileges and further advanced properties.
• Columns, Hierarchies, Variables/Input Parameters
Classify columns as Attributes and Measures
specify measure aggregation, if hidden, label
columns, filter variables, measures folder, …
Define hierarchies, variables, Input parameters
Column Semantic-type can be specified and
full unit/currency conversion specifications
Calculated column definition reviewed
Where-used analysis of columns
© 2012 SAP AG. All rights reserved. 51 Public
Graphical Calculation View – Save, Activate and Preview
Create an executable version of the calculation view and preview
• Save the view: Creates a Repository/Design-Time Object
• Activate the view: Creates a Catalog/Run-Time Object
Activation will create the Column view that can be accessed by the front end
tools or call the preview .
In calculation views, data preview is also supported
for intermediate nodes
Column Store
Activate
Extending Models with advanced capabilities
© 2012 SAP AG. All rights reserved. 53 Public
HANA Hierarchies
Authoring Hierarchies in Attribute- and Calculation Views
• Hierarchy is a description of responsibilities /relationship of the different
units/member that run the unit.
• This relationship help to visualize the data for analytical purpose by organizing the
same based on the relationship of various level of units / members.
• In SAP HANA, we have a choice of creating 2 types of hierarchies,
Level Hierarchy
Parent Child Hierarchy
• HANA Hierarchies can only be used by Multidimensional Reporting Clients.
© 2012 SAP AG. All rights reserved. 54 Public
HANA Hierarchies - Level Hierarchies
Level Hierarchy
Each level represents a position in the hierarchy
It can be something related to time (Year, Quarter, Month, Day) or geography (Country, Region, State).
Level Hierarchies are relatively easy as the various levels are either stored in different columns of the table or even
in different tables (snow flake).
© 2012 SAP AG. All rights reserved. 55 Public
HANA Hierarchies - Parent Child Hierarchies
Parent Child Hierarchy
Represents the relationship which is recursive in nature.
Defined as 2 table columns as pairs of predecessor and successor node IDs.
Modeled in HANA by taking input as a FLAT table where the rows corresponds to the Hierarchy nodes and contains
a node Id and a parent node id.
Examples :
Company organizational structure
Object levels: President – Vice President – Director
Object type: Person
Inventory BOM (Bill of Materials)
Object levels: Product – Assembly – Sub-Assembly – Component
Object type: Inventory item
© 2012 SAP AG. All rights reserved. 56 Public
HANA Hierarchies - Example of Parent Child Hierarchy
EMP
EMP_ID
FIRST_NAME
LAST_NAME
DEPT_NO
MGR_ID
For example, a company organization chart is made up of people. Some people are at
different levels, and there are therefore relationships from one person to another. In order to
show all of the relationships from the top of the company to the bottom (or the bottom to the
top) We have to keep going back to the same table. That is recursion
MGR
EMP_ID
FIRST_NAME
LAST_NAME
DEPT_NO
MGR_ID
Alias EMP_ID LAST_NAME MGR_ID
101 Frazier ?
102 Arthur 101
103 Greene 101
104 Rob 103
105 Bob 103
© 2012 SAP AG. All rights reserved. 57 Public
SAP HANA Currency Conversion
HANA Currency Conversion logic follows the identical logic of the SAP ERP Currency
Conversion. There is no refactoring!
Referencing ABAP function modules implementation: CONVERT_TO_LOCAL_CURRENCY,
CONVERT_TO_FOREIGN_CURRENCY
Inherits SAP ERP decimal and rounding inaccuracy
Inherits SAP ERP decimal shift problematic (e.g. Japanese Yen, Bahrain Dollar, …)
Pre-requisites SAP ERP currency tables and configuration (TCUR* tables)
Conversion is SAP Client dependent
© 2012 SAP AG. All rights reserved. 58 Public
SAP HANA Currency Conversion – Using CC with Measures
1. Define a calculated measure
3. Set the source amount column
4. Set the target currency:
• fixed value
• target currency column
• input parameter
5. Fill in all other conversion parameters: • source currency column • exchange type • conversion date column • Behavior on conversion failure
2. Set the default schema, where the SAP ERP TCUR*-tables are stored
© 2012 SAP AG. All rights reserved. 59 Public
SAP HANA Analytical Privileges
Analysis authorizations for HANA Information Models
• Analysis authorizations for row-level security
Can be based on attributes in analytic views
• Analytic privilege is always a concrete implementation
I.e. Specific authorization for specified values of given attribute
you have to create privileges for each group of users
or define dynamic analytic priviledges
Building SQL-Script-based
Calculation Views
© 2012 SAP AG. All rights reserved. 61 Public
Modeling Custom Scenarios – SQL Script-based Calculation Views
Scripts-based Calculation Views
• Calculation Views are side affect free / READ-ONLY functions
• Use of custom SQLScript to build Calculation Views
Write SQLScript CE-functions or standard SQL-statements with raw tables or
modeled views (preferred)
Define output structure,
activation creates column
store based on
Script Output
Semantic Node
© 2012 SAP AG. All rights reserved. 62 Public
Modeling Custom Scenarios – SQL Script-based Calculation Views
Scripts-based Calculation Views
• Use of custom SQLScript to build Calculation Views
Calculation Engine functions should not be mixed with standard SQL statements
Client queries can be well optimized and parallelized by the CE engine
Usually much better performance results than calculation view via standard SQL
Preferred
• Parallel query execution
• Only selected fields will be fetched
© 2012 SAP AG. All rights reserved. 63 Public
Excursus SQLScript – Standard SQL and CE-functions
SQL CE function
SELECT on column table out = SELECT A, B, C from "COLUMN_TABLE" out = CE_COLUMN_TABLE("COLUMN_TABLE", [A, B, C])
SELECT on attribute view out = SELECT A, B, C from "ATTRIBUTE_VIEW" out = CE_JOIN_VIEW("ATTRIBUTE_VIEW", [A, B, C])
SELECT on analytic view out = SELECT A, B, C, SUM(D) from "ANALYTIC_VIEW" GROUP BY
A, B, C
out = CE_OLAP_VIEW("ANALYTIC_VIEW", [A, B, C]);
WHERE HAVING out = SELECT A, B, C, SUM(D) from "ANALYTIC_VIEW" WHERE B =
'value' AND C = 'value'
col_tab= CE_COLUMN_TABLE("COLUMN_TABLE"); out = CE_PROJECTION(col_tab,
[A, B, C], ' "B" = ''value'' AND "C" = ''value'' ');
GROUP BY out = SELECT A, B, C, SUM(D) FROM"COLUMN_TABLE" GROUP
BY A, B, C
col_tab= CE_COLUMN_TABLE("COLUMN_TABLE"); out = CE_AGGREGATION(
(col_tab, SUM(D), [A, B, C]);
INNER JOIN out = SELECT A, B, Y, SUM(D) from "COLTAB1" INNER JOIN
"COLTAB2" WHERE "COLTAB1"."KEY1" = "COLTAB2"."KEY1" AND
"COLTAB1"."KEY2" = "COLTAB2"."KEY2"
out = CE_JOIN("COLTAB1","COLTAB2", [KEY1, KEY2], [A, B, Y, D])
LEFT OUTER JOIN out = SELECT A, B, Y, SUM(D) from "COLTAB1" LEFT OUTER JOIN
"COLTAB2" WHERE "COLTAB1"."KEY1" = "COLTAB2"."KEY1" AND
"COLTAB1"."KEY2" = "COLTAB2"."KEY2"
out = CE_LEFT_OUTER_JOIN("COLTAB1","COLTAB2", [KEY1, KEY2], [A, B, Y, D])
SQL Expressions out = SELECT A, B, C, SUBSTRING(D,2,5) FROM
"COLUMN_TABLE"
proj_tab = CE_COLUMN_TABLE("COLUMN_TABLE"); out = CE_PROJECTION(
:proj_tab, ["A", "B", "C", CE_CALC('midstr("D",2,5)', string) ]);
UNION ALL col_tab1 = SELECT A, B, C, D FROM "COLUMN_TABLE1"; col_tab2
= SELECT A, B, C, D FROM "COLUMN_TABLE2"; out = SELECT *
FROM :col_tab1 UNION ALL SELECT * FROM :col_tab2;
col_tab1 = CE_COLUMN_TABLE("COLUMN_TABLE1",[A,B,C,D]); col_tab2 =
CE_COLUMN_TABLE("COLUMN_TABLE2",[A,B,C,D]); out =
CE_UNION_ALL(:col_tab1,:col_tab2);
© 2012 SAP AG. All rights reserved. 64 Public
Modeling Custom Scenarios – SQL Script-based Calculation Views
Scripts-based Calculation Views
• Invoke and consume other functions from within Script-based calculation
Stored Procedures built in CE or generic SQL
Read-only / Read-write procedures can be created
IN (Input) parameters can be of scalar or table type
OUT (Output) parameters must be of table type
Tables types required are generated automatically
Invoke via Procedure CALL
Stored Procedure
General Modeling Principles
© 2012 SAP AG. All rights reserved. 66 Public
SAP HANA General Modeling Principles
Column
Store
Analytical
Views
Attribute
Views
Calculation Views
Client / Application
A B C D
A B C D G Y
A G Y
A G Y Z
Filter data amount as early as possible in the lower layers (CONSTRAINTS, WHERE Clause, Analytical Privileges..)
Aggregate data records (e.g using GROUP BY, reducing Coulmns)
Avoid transfer data of large resultsets between the HANA DB and client application
- Do calculation after aggregation.
- Avoid Complex expressions (IF, CASE, ... )
Join on Key Columns or Indexed Columns
Avoid calculations before aggregation on line item level
Reduce data transfer between views
© 2012 SAP AG. All rights reserved. 67 Public
Disclaimer
This presentation outlines our general product direction and should not be relied on in making
a purchase decision. This presentation is not subject to your license agreement or any other
agreement with SAP.
SAP has no obligation to pursue any course of business outlined in this presentation or to
develop or release any functionality mentioned in this presentation. This presentation and
SAP’s strategy and possible future developments are subject to change and may be changed
by SAP at any time for any reason without notice.
This document is provided without a warranty of any kind, either express or implied, including
but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or
non-infringement. SAP assumes no responsibility for errors or omissions in this document,
except if such damages were caused by SAP intentionally or grossly negligent.
Thank you
Contact information
Christoph Morgen
SAP HANA Product Management
AskSAPHANA@sap.com
To get the best overview of what’s new in SAP HANA SPS 07, read this blog.
© 2012 SAP AG. All rights reserved. 69 Public
© 2013 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and
SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in
the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other
countries.
Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.
top related