Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(udf): incorrect error handling of non-batched UDF #20473

Open
fuyufjh opened this issue Feb 12, 2025 · 0 comments
Open

bug(udf): incorrect error handling of non-batched UDF #20473

fuyufjh opened this issue Feb 12, 2025 · 0 comments
Labels
type/bug Something isn't working
Milestone

Comments

@fuyufjh
Copy link
Member

fuyufjh commented Feb 12, 2025

Describe the bug

For non-batched UDFs, the users expect the function to be executed row by row. If exception is thrown, the corresponding row should get a NULL result.

However, due to the current implementation of UDF framework, the actual behavior is: once a function failed, the whole batch will fail and NULLs will be filled for all these rows.

Even worse, this actually produce inconsistent data to downstream, because the behavior depends on how the input data was chunked.

Error message/log

NA

To Reproduce

CREATE FUNCTION divide(n INTEGER) RETURNS FLOAT 
LANGUAGE JAVASCRIPT AS $$
    export function divide(n) {
        if (n === 0) {
            throw new Error("Division by zero!");
        }
        return 100 / n;
    }
$$;

CREATE TABLE input (
    value INTEGER
);

INSERT INTO input SELECT generate_series(-10, 10);

CREATE MATERIALIZED VIEW result AS
SELECT 
    value,
    divide(value) as result
FROM input

SELECT * from result;

You will see multiple results are null.

Another problem is delete from input doesn't work... Didn't investigate yet, perhaps because of the data inconsistency.

Expected behavior

Only one row is null in the result.

How did you deploy RisingWave?

No response

The version of RisingWave

No response

Additional context

No response

@fuyufjh fuyufjh added the type/bug Something isn't working label Feb 12, 2025
@github-actions github-actions bot added this to the release-2.3 milestone Feb 12, 2025
@fuyufjh fuyufjh changed the title bug: error handling of non-batched UDF bug(udf): incorrect error handling of non-batched UDF Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant