Skip to content

Conversation

@SanjulaGanepola
Copy link
Member

@SanjulaGanepola SanjulaGanepola commented Oct 10, 2025

Changes

This PR adds udtf as a new SQL prefix for generating the skeleton for a user-defined table function as requested in #458

image

Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
@SanjulaGanepola SanjulaGanepola requested review from a team and forstie October 10, 2025 00:16
@github-actions
Copy link

github-actions bot commented Oct 10, 2025

👋 A new build is available for this PR based on 7eb34da.

@forstie
Copy link
Collaborator

forstie commented Oct 10, 2025

I think we should add some of the most important UDTF keywords.

NOT DETERMINISTIC
NO EXTERNAL ACTION
READS SQL DATA
SET OPTION
COMMIT = *NONE ,
DYNUSRPRF = *USER ,
USRPRF = *USER

@SanjulaGanepola
Copy link
Member Author

I think we should add some of the most important UDTF keywords.

Done! I updated the screen cap above

@forstie
Copy link
Collaborator

forstie commented Oct 11, 2025

ON Common1, I did
udtf: select * from dogshow.account

Any and all columns returned by the udtf should be referenced by name.
Using SELECT * means that the UDTF will break when a column is added later.

`-- statement:
-- select * from dogshow.account

-- User-defined table function
CREATE OR REPLACE FUNCTION MyFunction()
RETURNS TABLE (
CLINAME VARCHAR(100)
)
NOT DETERMINISTIC
NO EXTERNAL ACTION
READS SQL DATA
SET OPTION COMMIT = *NONE,
DYNUSRPRF = *USER,
USRPRF = *USER
BEGIN
RETURN select * from dogshow.account;
END;`

@forstie
Copy link
Collaborator

forstie commented Oct 11, 2025

Delimited column names aren't handled by the support.
Example:


-- statement:
-- update: SELECT "cLo" FROM "CaMel"."CoWt"

-- User-defined table function
CREATE OR REPLACE FUNCTION MyFunction()
  RETURNS TABLE (
    cLo INTEGER
  )
  NOT DETERMINISTIC
  NO EXTERNAL ACTION
  READS SQL DATA
  SET OPTION COMMIT = *NONE,
             DYNUSRPRF = *USER,
             USRPRF = *USER
  BEGIN
    RETURN SELECT * FROM "CaMel"."CoWt";
  END;

Copy link
Contributor

@chrjorgensen chrjorgensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SanjulaGanepola See comments by @forstie for required changes.

@SanjulaGanepola
Copy link
Member Author

@forstie @chrjorgensen This PR is ready for review and testing again.

udtf: select * from dogshow.account
-- statement:
-- select * from dogshow.account

-- User-defined table function
CREATE OR REPLACE FUNCTION MyFunction()
  RETURNS TABLE (
    CLINAME VARCHAR(100)
  )
  NOT DETERMINISTIC
  NO EXTERNAL ACTION
  READS SQL DATA
  SET OPTION COMMIT = *NONE,
             DYNUSRPRF = *USER,
             USRPRF = *USER
  BEGIN
    RETURN select CLINAME
            from dogshow.account;
  END;
udtf: SELECT "cLo" FROM "CaMel"."CoWt"
-- statement:
-- SELECT "cLo" FROM "CaMel"."CoWt"

-- User-defined table function
CREATE OR REPLACE FUNCTION MyFunction()
  RETURNS TABLE (
    cLo INTEGER
  )
  NOT DETERMINISTIC
  NO EXTERNAL ACTION
  READS SQL DATA
  SET OPTION COMMIT = *NONE,
             DYNUSRPRF = *USER,
             USRPRF = *USER
  BEGIN
    RETURN SELECT "cLo" FROM "CaMel"."CoWt";
  END;

@forstie
Copy link
Collaborator

forstie commented Dec 4, 2025

CEAC had a good comment in general, that applies here.

We could include DBGVIEW = *SOURCE in the Set Option statement.
Or at least include it commented out?

@forstie
Copy link
Collaborator

forstie commented Dec 4, 2025

I think I have the vsix properly updated.
I am seeing...

udtf: select * from dogshow.account;

Create this, which is wrong

-- User-defined table function
CREATE OR REPLACE FUNCTION MyFunction()
RETURNS TABLE (
CLINAME VARCHAR(100)
)
NOT DETERMINISTIC
NO EXTERNAL ACTION
READS SQL DATA
SET OPTION COMMIT = *NONE,
DYNUSRPRF = *USER,
USRPRF = *USER
BEGIN
RETURN CLINAME
select * from dogshow.account;
END;

Signed-off-by: Sanjula Ganepola <[email protected]>
@SanjulaGanepola
Copy link
Member Author

@forstie
Copy link
Collaborator

forstie commented Dec 6, 2025

I did the install over again, cmd-Q to kill vs, restarted and still see this
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL prefixes add prefix to create SQL table function return list

4 participants