diff --git a/dataForHANACloud.tar.gz b/dataForHANACloud.tar.gz index a9b3998..d5242ff 100644 Binary files a/dataForHANACloud.tar.gz and b/dataForHANACloud.tar.gz differ diff --git a/runtimes/cpp/Sample/linux.mak b/runtimes/cpp/Sample/linux.mak index e51ad7c..5a440ac 100644 --- a/runtimes/cpp/Sample/linux.mak +++ b/runtimes/cpp/Sample/linux.mak @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- -# Copyright....: (c) SAP 1999-2021 +# Copyright....: (c) SAP 1999-2023 # Project......: # Library......: # File.........: linux.mak diff --git a/runtimes/cpp/Sample/win.mak b/runtimes/cpp/Sample/win.mak index 5d8abda..b465296 100644 --- a/runtimes/cpp/Sample/win.mak +++ b/runtimes/cpp/Sample/win.mak @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- -# Copyright....: (c) SAP 1999-2021 +# Copyright....: (c) SAP 1999-2023 # Project......: # Library......: # File.........: win.mak diff --git a/runtimes/cpp/Sample/win_X64-WIN64-VC15.mak b/runtimes/cpp/Sample/win_X64-WIN64-VC22.mak similarity index 91% rename from runtimes/cpp/Sample/win_X64-WIN64-VC15.mak rename to runtimes/cpp/Sample/win_X64-WIN64-VC22.mak index a530311..9937b19 100644 --- a/runtimes/cpp/Sample/win_X64-WIN64-VC15.mak +++ b/runtimes/cpp/Sample/win_X64-WIN64-VC22.mak @@ -1,17 +1,17 @@ -# ---------------------------------------------------------------------------- -# Copyright....: (c) SAP 1999-2021 -# Project......: -# Library......: -# File.........: win.mak -# Author.......: -# Created......: Tue Mar 09 16:51:38 2010 -# Description..: -# -# CVS infos....: -# .............. $Id: win_X64-WIN64.mak,v 1.2 2012/05/30 10:28:17 port Exp $ -# .............. $Date: 2012/05/30 10:28:17 $ -# .............. $Revision: 1.2 $ -# ---------------------------------------------------------------------------- - -# Some macros for SUN OS compiler +# ---------------------------------------------------------------------------- +# Copyright....: (c) SAP 1999-2023 +# Project......: +# Library......: +# File.........: win.mak +# Author.......: +# Created......: Tue Mar 09 16:51:38 2010 +# Description..: +# +# CVS infos....: +# .............. $Id: win_X64-WIN64.mak,v 1.2 2012/05/30 10:28:17 port Exp $ +# .............. $Date: 2012/05/30 10:28:17 $ +# .............. $Revision: 1.2 $ +# ---------------------------------------------------------------------------- + +# Some macros for SUN OS compiler include win_X64-WIN64.mak \ No newline at end of file diff --git a/runtimes/cpp/Sample/win_X64-WIN64.mak b/runtimes/cpp/Sample/win_X64-WIN64.mak index 5d4b007..8806abe 100644 --- a/runtimes/cpp/Sample/win_X64-WIN64.mak +++ b/runtimes/cpp/Sample/win_X64-WIN64.mak @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- -# Copyright....: (c) SAP 1999-2021 +# Copyright....: (c) SAP 1999-2023 # Project......: # Library......: # File.........: win.mak diff --git a/runtimes/java/KxJRT.jar b/runtimes/java/KxJRT.jar index 3c407a4..dd1c57e 100644 Binary files a/runtimes/java/KxJRT.jar and b/runtimes/java/KxJRT.jar differ diff --git a/sql/check_apl/check_apl.sql b/sql/check_apl/check_apl.sql index 3849fa0..5daadc8 100644 --- a/sql/check_apl/check_apl.sql +++ b/sql/check_apl/check_apl.sql @@ -1346,7 +1346,7 @@ BEGIN :final_results.insert(('==============================','','')); END IF; -- keep using LOWER. This is not a mistake - SELECT LOWER(SESSION_USER) into who_am_i FROM "DUMMY"; + SELECT SUBSTR(LOWER(SESSION_USER),0,9) into who_am_i FROM "DUMMY"; IF :who_am_i <> 'check_apl' AND :who_am_i<>'rouser' THEN -- do the final check and pop an sql error @@ -1354,7 +1354,7 @@ BEGIN SELECT COUNT(*) into nb_issues FROM :final_results WHERE "STATUS" IN ('ISSUE','ERROR'); IF :nb_issues > 0 THEN - SELECT '['||STRING_AGG("KEY" || ' ' || COALESCE("STATUS",'') || ' ' || COALESCE("DETAILS",'') || CHAR(10))||']' INTO error_message FROM :final_results; + SELECT SUBSTR('['||STRING_AGG("KEY" || ' ' || COALESCE("STATUS",'') || ' ' || COALESCE("DETAILS",'') || CHAR(10))||']',0,3000) INTO error_message FROM :final_results; SIGNAL ERROR_APL set MESSAGE_TEXT = :error_message; END IF; END IF; diff --git a/sql/check_apl/check_apl_without_creating_check_apl_user.sql b/sql/check_apl/check_apl_without_creating_check_apl_user.sql index c08d544..dcc2c01 100644 --- a/sql/check_apl/check_apl_without_creating_check_apl_user.sql +++ b/sql/check_apl/check_apl_without_creating_check_apl_user.sql @@ -1279,7 +1279,7 @@ BEGIN :final_results.insert(('==============================','','')); END IF; -- keep using LOWER. This is not a mistake - SELECT LOWER(SESSION_USER) into who_am_i FROM "DUMMY"; + SELECT SUBSTR(LOWER(SESSION_USER),0,9) into who_am_i FROM "DUMMY"; IF :who_am_i <> 'check_apl' AND :who_am_i<>'rouser' THEN -- do the final check and pop an sql error @@ -1287,7 +1287,7 @@ BEGIN SELECT COUNT(*) into nb_issues FROM :final_results WHERE "STATUS" IN ('ISSUE','ERROR'); IF :nb_issues > 0 THEN - SELECT '['||STRING_AGG("KEY" || ' ' || COALESCE("STATUS",'') || ' ' || COALESCE("DETAILS",'') || CHAR(10))||']' INTO error_message FROM :final_results; + SELECT SUBSTR('['||STRING_AGG("KEY" || ' ' || COALESCE("STATUS",'') || ' ' || COALESCE("DETAILS",'') || CHAR(10))||']',0,3000) INTO error_message FROM :final_results; SIGNAL ERROR_APL set MESSAGE_TEXT = :error_message; END IF; END IF; diff --git a/sql/procedure/apl_samples/timeseries/apl_apply_proc.sql b/sql/procedure/apl_samples/timeseries/apl_apply_proc.sql index 66e82a6..848071a 100644 --- a/sql/procedure/apl_samples/timeseries/apl_apply_proc.sql +++ b/sql/procedure/apl_samples/timeseries/apl_apply_proc.sql @@ -60,3 +60,28 @@ BEGIN "SAP_PA_APL"."sap.pa.apl.base::CREATE_TABLE_FROM_TABLE_TYPE"(:apply_out_schema, :apply_out_table, :out_schema); "SAP_PA_APL"."sap.pa.apl.base::APPLY_MODEL"(:header, :model, :config, :apply_in_schema, :apply_in_table, :apply_out_schema, :apply_out_table , out_apply_log, out_apply_sum); END; + + + +drop PROCEDURE "apl_apply_debrief_example"; +CREATE PROCEDURE "apl_apply_debrief_example" ( + IN header "SAP_PA_APL"."sap.pa.apl.base::BASE.T.FUNCTION_HEADER", + IN model "SAP_PA_APL"."sap.pa.apl.base::BASE.T.MODEL_BIN_OID", + IN config "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_CONFIG_EXTENDED", + IN apply_in_schema VARCHAR (127), + IN apply_in_table VARCHAR (127), + IN apply_out_schema VARCHAR (127), + IN apply_out_table VARCHAR (127), + OUT out_apply_log "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_LOG", + OUT out_apply_sum "SAP_PA_APL"."sap.pa.apl.base::BASE.T.SUMMARY", + OUT out_debrief_metric "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_METRIC_OID", + OUT out_debrief_property "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_PROPERTY_OID" +) +LANGUAGE SQLSCRIPT +SQL SECURITY INVOKER AS +BEGIN + "SAP_PA_APL"."sap.pa.apl.base::GET_TABLE_TYPE_FOR_APPLY"(:header, :model, :config, :apply_in_schema, :apply_in_table,out_schema, out_log); + "drop_table_if_exit"(:apply_out_schema, :apply_out_table); + "SAP_PA_APL"."sap.pa.apl.base::CREATE_TABLE_FROM_TABLE_TYPE"(:apply_out_schema, :apply_out_table, :out_schema); + "SAP_PA_APL"."sap.pa.apl.base::APPLY_MODEL_DEBRIEF"(:header, :model, :config, :apply_in_schema, :apply_in_table, :apply_out_schema, :apply_out_table , out_apply_log, out_apply_sum,out_debrief_metric,out_debrief_property); +END; diff --git a/sql/procedure/apl_samples/timeseries/apl_create_model_train_apply_debrief.sql b/sql/procedure/apl_samples/timeseries/apl_create_model_train_apply_debrief.sql new file mode 100644 index 0000000..2250a5d --- /dev/null +++ b/sql/procedure/apl_samples/timeseries/apl_create_model_train_apply_debrief.sql @@ -0,0 +1,88 @@ +-- @required(hanaMinimumVersion,2.0.40) +-- ================================================================ +-- APL_AREA, FORECAST +-- Description : +-- Assumption 1: the users & privileges have been created & granted (see apl_admin_ex.sql). +-- @depend(apl_apply_proc.sql) + +connect USER_APL password Password1; +SET SESSION 'APL_CACHE_SCHEMA' = 'APL_CACHE'; + + +-- -------------------------------------------------------------------------- +-- Create a view which contains the sorted dataset +-- -------------------------------------------------------------------------- + +drop view CASHFLOWS_SORTED; +create view CASHFLOWS_SORTED as select * from APL_SAMPLES.CASHFLOWS_FULL order by "Date" asc; + +-- -------------------------------------------------------------------------- +-- Create the input/output tables used as arguments for the APL function +-- -------------------------------------------------------------------------- +drop table MODEL_BIN_OUT; +create table MODEL_BIN_OUT like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.MODEL_BIN_OID"; + +drop table OPERATION_LOG; +create table OPERATION_LOG like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_LOG"; + +drop table SUMMARY; +create table SUMMARY like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.SUMMARY"; + +drop table INDICATORS; +create table INDICATORS like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.INDICATORS"; + +drop table APPLY_LOG; +create column table APPLY_LOG like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_LOG"; + +drop table APPLY_SUMMARY; +create column table APPLY_SUMMARY like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.SUMMARY"; + +drop table APPLY_DEBRIEF_METRIC; +create table APPLY_DEBRIEF_METRIC like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_METRIC_OID"; + +drop table APPLY_DEBRIEF_PROPERTY; +create table APPLY_DEBRIEF_PROPERTY like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_PROPERTY_OID"; + +drop table APPLY_OUT; + +DO BEGIN + declare header "SAP_PA_APL"."sap.pa.apl.base::BASE.T.FUNCTION_HEADER"; + declare config "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_CONFIG_EXTENDED"; + declare apply_config "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_CONFIG_EXTENDED"; + declare var_desc "SAP_PA_APL"."sap.pa.apl.base::BASE.T.VARIABLE_DESC_OID"; + declare var_role "SAP_PA_APL"."sap.pa.apl.base::BASE.T.VARIABLE_ROLES_WITH_COMPOSITES_OID"; + + :header.insert(('Oid', '#42')); + :header.insert(('LogLevel', '8')); + :header.insert(('ModelFormat', 'bin')); + + :config.insert(('APL/ModelType', 'timeseries',null)); + :config.insert(('APL/Horizon', '20',null)); + :config.insert(('APL/TimePointColumnName', 'Date',null)); + :config.insert(('APL/LastTrainingTimePoint', '2001-12-29 00:00:00',null)); + :config.insert(('APL/WithExtraPredictable', 'false',null)); + :config.insert(('APL/ForcePositiveForecast', 'true',null)); + + :var_role.insert(('Date', 'input',null,null,null)); + :var_role.insert(('Cash', 'target',null,null,null)); + + insert into :var_desc select *,'42' from APL_SAMPLES.CASHFLOWS_DESC; + + "SAP_PA_APL"."sap.pa.apl.base::CREATE_MODEL_AND_TRAIN"(:header, :config, :var_desc,:var_role, 'USER_APL','CASHFLOWS_SORTED', model, train_log, train_sum, train_indic); + + call "apl_apply_debrief_example"(:header, :model, :config, 'USER_APL','CASHFLOWS_SORTED', 'USER_APL','APPLY_OUT',out_apply_log,out_apply_sum,out_debrief_metric, out_debrief_property); + + -- store result into table + insert into "USER_APL"."MODEL_BIN_OUT" select * from :model; + insert into "USER_APL"."OPERATION_LOG" select * from :train_log; + insert into "USER_APL"."SUMMARY" select * from :train_sum; + insert into "USER_APL"."INDICATORS" select * from :train_indic; + insert into "USER_APL"."APPLY_LOG" select * from :out_apply_log; + insert into "USER_APL"."APPLY_SUMMARY" select * from :out_apply_sum; + insert into "USER_APL"."APPLY_DEBRIEF_PROPERTY" select * from :out_debrief_property; + insert into "USER_APL"."APPLY_DEBRIEF_METRIC" select * from :out_debrief_metric; +END; + +select * from "USER_APL"."APPLY_OUT"; +select * from "USER_APL"."APPLY_DEBRIEF_PROPERTY"; +select * from "USER_APL"."APPLY_DEBRIEF_METRIC"; diff --git a/sql/procedure/apl_samples/timeseries/segmented_apply_debrief.sql b/sql/procedure/apl_samples/timeseries/segmented_apply_debrief.sql new file mode 100644 index 0000000..0276c0f --- /dev/null +++ b/sql/procedure/apl_samples/timeseries/segmented_apply_debrief.sql @@ -0,0 +1,67 @@ +-- @required(hanaMinimumVersion,2.0.40) +-- ================================================================ +-- APL_AREA, APPLY_MODEL, using a binary format for the model +-- This script demonstrates the application of the binary classification model +-- to predict the target and to get the individual contributions per input +-- +-- Assumption 1: The users & privileges have been created & granted (see apl_admin_ex.sql). +-- Assumption 2: There's a valid trained model (created by APL) in the MODEL_TRAIN_BIN table. +-- @depend(segmented_create_train.sql) +-- @depend(apl_apply_proc.sql) +connect USER_APL password Password1; +SET SESSION 'APL_CACHE_SCHEMA' = 'APL_CACHE'; + +drop table APPLY_OPERATION_LOG; +create table APPLY_OPERATION_LOG like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_LOG"; + +drop table APPLY_SUMMARY; +create table APPLY_SUMMARY like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.SUMMARY"; + +drop table APPLY_DEBRIEF_METRIC; +create table APPLY_DEBRIEF_METRIC like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_METRIC_OID"; + +drop table APPLY_DEBRIEF_PROPERTY; +create table APPLY_DEBRIEF_PROPERTY like "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_PROPERTY_OID"; + + +DO BEGIN + declare header "SAP_PA_APL"."sap.pa.apl.base::BASE.T.FUNCTION_HEADER"; + declare config "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_CONFIG_EXTENDED"; + declare model "SAP_PA_APL"."sap.pa.apl.base::BASE.T.MODEL_BIN_OID"; + declare out_log "SAP_PA_APL"."sap.pa.apl.base::BASE.T.OPERATION_LOG"; + declare out_sum "SAP_PA_APL"."sap.pa.apl.base::BASE.T.SUMMARY"; + declare out_debrief_metric "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_METRIC_OID"; + declare out_debrief_property "SAP_PA_APL"."sap.pa.apl.base::BASE.T.DEBRIEF_PROPERTY_OID"; + + insert into :model select * from MODEL_TRAIN_BIN; + + :header.insert(('Oid', '#42')); + :header.insert(('LogLevel', '8')); + :header.insert(('ModelFormat', 'bin')); + :header.insert(('MaxTasks', '2')); -- define nb parallel tasks to use for train + + :config.insert(('APL/SegmentColumnName', 'Seg',null)); -- define the column used as the segmentation colum + :config.insert(('APL/ApplyLastTimePoint', '2001-12-29 00:00:00',null)); + + call "apl_apply_debrief_example"(:header, :model, :config, 'USER_APL','CASHFLOWS_SORTED', 'USER_APL','APPLY_OUT',out_log,out_sum,out_debrief_metric, out_debrief_property); + + insert into APPLY_OPERATION_LOG select * from :out_log; + insert into APPLY_SUMMARY select * from :out_sum; + insert into APPLY_DEBRIEF_PROPERTY select * from :out_debrief_property; + insert into APPLY_DEBRIEF_METRIC select * from :out_debrief_metric; +END; + +--SELECT * from CASHFLOWS_SORTED; +SELECT "Seg", count(*) from APPLY_OUT group by "Seg"; + +-- Nb trained models +select count(*) from APPLY_SUMMARY where "KEY" = 'AplTaskElapsedTime'; + +-- Average time to train a segment +select AVG(to_double("VALUE")) from APPLY_SUMMARY where "KEY" = 'AplTaskElapsedTime'; + +-- Total time +select * from APPLY_SUMMARY where "KEY" = 'AplTotalElapsedTime'; + +-- Get models in error +select * from APPLY_OPERATION_LOG where "LEVEL" = 0;