A window will pop-up. Click on Open next to SAP HANA Vora Tools to connect to Vora
Data Modeler for the purpose of this exercise.
USING com.sap.spark.vora
OPTIONS
(tableName "CUSTOMER_TEXT", paths "/user/vora/customer_text_data.csv");
-SELECT * FROM CUSTOMER;
Create Joins
Scenario 1:
1. Create a SQL view as STAR_CUSTOMERS
2. Drag and drop a subselect to your view, and add an alias as CUSTOMER_INFO"
3. Now we want to select dierent attributes for the customers and for that we need to
join CUSTOMER and CUSTOMER_GROUP: Double click on the subselect which you
created in step 2 and add CUSTOMER and CUSTOMER_GROUP as data sources
4. Add CUSTOMER_GROUP table the same way you added CUSTOMER table.
5. To create a join between these two tables, highlight the CUSTOMER table and click on
the join symbol as is shown in the following image and drag and drop it to
CUSTOMER_GROUP table.
6. The join window will pop up as below. Click on propose condition and you see the
common column between two tables are added as join condition. Please note that we
accepted the default type of join which is INNER join but you can change it by clicking
on the arrow next to the Type.
9. Click on the Star on top of your subselect rectangle to add all the selected columns to
the output of the view and then save your work.
Create Unions
We want to create union of the SALES and SALES_2015 tables in order to have the sales
data from 2013-2015.
10. Add SALES a from datasources same way you added CUSTOMER datasource in step
3.
11. Join the CUSTOMER_INFO with SALES table as you did in step 6.
14. Add a resultset and use its arrow to create the connection to CUSTOMER_INFO or
SALES
15. Add another Resultset and draw a connection with the CUSTOMER or SALES_2015
table
16. Draw a connection between the one Resultset to another, using the 8 icon. By default,
the 1st result from where the union was initiated, is marked as Default ResultSet.
18. Now, Save your result and press on the SQL button to create the generated SQL and
click on close
SELECT CUSTOMER_INFO.CUSTOMER_ID , YEAR , REVENUE
FROM SALES_P
INNER JOIN ( SELECT CUSTOMER_ID , CUSTOMER_GROUP.CUSTOMER_GROUP ,
LOCATION , CATEGORY_ABBREVIATION
FROM CUSTOMER
INNER JOIN CUSTOMER_GROUP
ON CUSTOMER.CUSTOMER_GROUP = CUSTOMER_GROUP.CUSTOMER_GROUP)
CUSTOMER_INFO
ON SALES_P.CUSTOMER_ID = CUSTOMER_INFO.CUSTOMER_ID
UNION
SELECT CUSTOMER.CUSTOMER_ID , YEAR , REVENUE
FROM SALES_2015
INNER JOIN CUSTOMER
ON SALES_2015.CUSTOMER_ID = CUSTOMER.CUSTOMER_ID
12. Go back to the SQL Editor view and paste the generated SQL and click on play button
to execute the statement.
13. Notice the result has the sales from 2015 as well.
SCENARIO 2:
objectives in this scenario is to get familiar with how to use Modeler artifacts to create
Group By, Aggregations, Order By, etc. We want to figure out the average revenue per
region per year.
14. Create a new and call it STAR_CUSTOMERS2 and add CUSTOMER and SALE as data
sources.
15. Create a join between CUSTOMER and SALE as showed in step 6 and choose the
following column for the result.
16. Right click on the Revenue and choose the Edit from the drop down menu. Then
choose the AVG as aggregation function in the popped up window and type AVG_REV
as Alias.
17. Add YEAR and REVENUE to GROUP BY Revenue per year per region