Table Completion
Introduction
This guide demonstrates how to use the SAP AI SDK for Java to predict targets in structured data using SAP RPT models deployed on SAP AI Core. Refer to the official SAP RPT documentation for more details.
All classes under any of the ...generated package are generated from an OpenAPI specification.
This means that these model and API classes are not guaranteed to be stable and may change with future releases.
They are safe to use, but may require updates even in minor releases.
Prerequisites
Before using the AI Core module, ensure that you have met all the general requirements outlined in the overview. Additionally, include the necessary Maven dependency in your project.
Maven Dependencies
Add the following dependency to your pom.xml file:
<dependencies>
<dependency>
<groupId>com.sap.ai.sdk.foundationmodels</groupId>
<artifactId>sap-rpt</artifactId>
<version>${ai-sdk.version}</version>
</dependency>
</dependencies>
See an example pom in our Spring Boot application
Usage
In addition to the prerequisites above, we assume you have already set up the following to carry out the examples in this guide:
-
A Deployed RPT Model in SAP AI Core
-
Refer to How to deploy a model to AI Core for setup instructions.
-
Example deployed model from the AI Core
/deploymentsendpoint{"id": "c4dfbfd3bet3d4f1","createdAt": "2026-01-14T06:29:33Z","modifiedAt": "2026-01-14T06:29:33Z","status": "RUNNING","details": {"scaling": {"backendDetails": {},"backend_details": {}},"resources": {"backendDetails": {"model": {"name": "sap-rpt-1-small","version": "latest"}},"backend_details": {"model": {"name": "sap-rpt-1-small","version": "latest"}}}},"scenarioId": "foundation-models","configurationId": "54fe1b6a-2d4b-4e2f-9f4b-5c8e9f1a2b3c","latestRunningConfigurationId": "54fe1b6a-2d4b-4e2f-9f4b-5c8e9f1a2b3c","lastOperation": "CREATE","targetStatus": "RUNNING","submissionTime": "2026-01-14T06:30:08Z","startTime": "2026-01-14T06:31:44Z","configurationName": "sap-rpt-1-small","deploymentUrl": "https://api.ai.intprod-eu12.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/c4dfbfd3bet3d4f1"}
-
Simple table completion
Predict missing targets in tabular data using RptClient with a SAP RPT model.
An RPT request is built from three objects, each with a distinct responsibility:
| Object | Purpose |
|---|---|
TargetColumnConfig | Tells RPT what to predict: the column name, the placeholder sentinel, and the task type (regression or classification). |
PredictionConfig | Wraps one or more TargetColumnConfig objects and attaches optional settings such as explanation requests. |
PredictRequestPayloadOneOf | Bundles the prediction config together with the actual row data and additional parameters, then sends it to RPT. |
// Declare column types explicitly so RPT does not have to infer them from row values.
var dataSchema = Map.of(
"fruit", SchemaFieldConfig.create().dtype(ColumnType.STRING),
"id", SchemaFieldConfig.create().dtype(ColumnType.STRING),
"category", SchemaFieldConfig.create().dtype(ColumnType.STRING));
// Rows with "[PREDICT]" as the value are the targets RPT will fill in.
List<Map<String, RowsInnerValue>> rows =
List.of(
Map.of(
"id", RowsInnerValue.create("1"),
"fruit", RowsInnerValue.create("Apple"),
"category", RowsInnerValue.create("[PREDICT]")),
Map.of(
"id", RowsInnerValue.create("2"),
"fruit", RowsInnerValue.create("Banana"),
"category", RowsInnerValue.create("Tropical")),
Map.of(
"id", RowsInnerValue.create("3"),
"fruit", RowsInnerValue.create("Mango"),
"category", RowsInnerValue.create("Tropical")));
Use CLASSIFICATION for discrete labels or categories, REGRESSION for continuous numeric values.
The predictionPlaceholder must match the sentinel value used in the rows above.
Choosing the wrong task type significantly degrades prediction quality.
var targetColumns =
List.of(
TargetColumnConfig.create()
.name("category")
.predictionPlaceholder(PredictionPlaceholder.create("[PREDICT]"))
.taskType(CLASSIFICATION));
indexColumn is the unique row key, preserved in the response to match predictions back to source rows.
parseDataTypes auto-detects numeric vs. categorical columns; without this, regression quality degrades significantly.
var request =
PredictRequestPayloadOneOf.create()
.predictionConfig(PredictionConfig.create().targetColumns(targetColumns))
.rows(rows)
.indexColumn("id")
.dataSchema(dataSchema)
.parseDataTypes(true);
PredictResponsePayload response = RptClient.forModel(SAP_RPT_1_5).tableCompletion(request);
The request payload is always GZIP compressed before sending.
Please find more to the example in the sample application including dataSchema specification.
Table Completion with Parquet Files
For larger datasets, you can provide data as a Parquet file instead of constructing the data structure in code.
The same TargetColumnConfig and PredictionConfig objects described above are reused here.
var parquetFile = new File("path/to/your/data.parquet");
var targetColumns =
List.of(
TargetColumnConfig.create()
.name("category")
.predictionPlaceholder(PredictionPlaceholder.create("[PREDICT]"))
.taskType(CLASSIFICATION));
var predictionConfig = PredictionConfig.create().targetColumns(targetColumns);
PredictResponsePayload response =
RptClient.forModel(SAP_RPT_1_5).tableCompletion(parquetFile, predictionConfig);
Please find more examples in the sample application.
Explanations
The tabular model can provide explanations:
- Column scores per query row, higher means more weight was put on this column.
- 2D array where each subarray contains indices of most relevant context rows for that query row. The first dimension indexes query rows, the second dimension indexes all rows as a sequential integer index.
var rows = ...;
var targetColumns = ...;
var predictionConfig =
PredictionConfig.create()
.targetColumns(targetColumns)
.explanations(ExplanationConfig.create().topColumnScores(3).topRelevantContextRows(3));
var request = PredictRequestPayloadOneOf.create().predictionConfig(predictionConfig).rows(rows);
PredictResponsePayload response = RptClient.forModel(SAP_RPT_1_5).tableCompletion(request);
ExplanationResult explanation = response.getExplanations();
List<Map<String, BigDecimal>> columnScores = explanations.getTopColumnScores();
// [{"ORDERDATE": 0.339, "PRICE": 0.291, "PRODUCT": 0.37}]
List<List<Integer>> relevantContextRows = explanations.getTopRelevantContextRows();
// [[1, 2]]
Please find more examples in the sample application.