2026 Jan 27 1:53 PM - edited 2026 Jan 27 3:28 PM
Hi everyone,
I am working with SQL Views using SQLScript (Table Function) in SAP Datasphere and noticed that the output columns must always be created manually in the Model Properties → Columns section before the SQLScript can be validated or deployed.
Even when the SQLScript contains a simple RETURN SELECT ... statement, Datasphere does not automatically generate the column definitions based on the SQL result. As far as I can see, this is different from standard SQL views, where column inference works automatically.
RETURN SELECT ...In all cases, Datasphere requires me to manually maintain the business/technical names and data types in the Model Properties panel before validation succeeds.
Example SQLScript:
return
with "cte_customers" as (
select
"id",
"name"
from "customers"
)
, "cte_customers_ranked" as (
select
"id",
"name",
1 as "rank_number"
from "cte_customers"
)
select
"id",
"name",
"rank_number"
from "cte_customers_ranked";Some way to auto‑populate the column list based on the SQLScript output (similar to SQL Standard views).
Columns must be fully defined manually, otherwise validation fails.
If anyone has additional insight, workaround ideas, or official SAP statements regarding this behavior, I would really appreciate it.
Thank you.
Kind regards,
Anna
tab =
select
"id" AS ID
from "customers";
return
select ID from :tab;
tab = with "cte1" (ID) as (
select
"id" AS ID
from "customers"
)
select ID from "cte1";
return
select ID from :tab;
WITH clause?Request clarification before answering.
Hey Anna,
The short answer is that the SQL editor is very - ehm - simple (but I'm sure it has a great personality).
The Editor will try to derive the columns from whatever it finds immediately after the "Return" statement.
It will put no effort into it, and any logic between the output and the source will break it.
Any kind of obfuscation between the editor and the source tables will result in the editor throwing it's hands in the air.
Here is a really basic example with a simple temp table between the source and the output:
Even this simple script confuses the poor things.
It does derive the columns, but everything is cast as a string(100).
Adding a new "Ranking" column, which is clearly an integer, will still result in a string(100).
If you already have an object with the structure you want; one thing that makes it less-awful, it to add a
return select * from sourceAnd validate. That will generate the structure and derive the schema correctly.
You can then write your script on top, and replace the "Return" statement later.
This is shaky at best, but it's the least awful way I found.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.