linrrzqqq opened a new pull request, #62950:
URL: https://github.com/apache/doris/pull/62950

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   Nereids resolves UDF calls from FunctionRegistry, while SHOW FUNCTIONS reads 
catalog
   metadata. After DROP DATABASE and recreating the same database name, catalog 
metadata
   could be empty but FunctionRegistry still contained stale Python UDF 
builders, causing
   SELECT to bind and execute the old function body.
   
   ```sql
   DROP DATABASE IF EXISTS registry_test_db
   CREATE DATABASE registry_test_db;
   USE registry_test_db;
   
   DROP FUNCTION IF EXISTS py_exc_cache_test(INT);
   CREATE FUNCTION py_exc_cache_test(INT)
   RETURNS INT
   PROPERTIES (
       "type" = "PYTHON_UDF",
       "symbol" = "evaluate",
       "runtime_version" = "3.12.11",
       "always_nullable" = "true"
   )
   AS $$
   def evaluate(x):
       if x is None:
           return None
       return x + 1
   $$;
   
   -- Normal operation
   SELECT py_exc_cache_test(10); -- 11
   
   -- Directly delete, but the code didn't clean up the FunctionRegistry under 
db.
   DROP DATABASE registry_test_db FORCE;
   CREATE DATABASE registry_test_db;
   USE registry_test_db;
   
   -- show functions 走catalog的 db.getFunctions()
   SHOW FUNCTIONS LIKE 'py_exc_cache_test'; 
   -- empty
   
   -- Function execution, go through FunctionRegistry, use the remaining 
FunctionRegistry, expected to be 11 (bug)
   SELECT py_exc_cache_test(10);
   
   -- Create a new function with the same name, but the execution logic is to 
append to the end of the Registry.
   -- Normal call still goes through the previous version of x + 1 after drop 
dp (bug)
   DROP FUNCTION IF EXISTS py_exc_cache_test(INT);
   CREATE FUNCTION py_exc_cache_test(INT)
   RETURNS INT
   PROPERTIES (
       "type" = "PYTHON_UDF",
       "symbol" = "evaluate",
       "runtime_version" = "3.12.11",
       "always_nullable" = "true"
   )
   AS $$
   def evaluate(x):
       if x is None:
           return None
       return x + 999
   $$;
   SELECT py_exc_cache_test(10); -- still 11 (bug)
   ```
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to