Ruben Q L created CALCITE-7772:
----------------------------------

             Summary: ModelHandler.addFunctions should defer UDF class 
initialization until after shape validation
                 Key: CALCITE-7772
                 URL: https://issues.apache.org/jira/browse/CALCITE-7772
             Project: Calcite
          Issue Type: Improvement
          Components: core
            Reporter: Ruben Q L


`ModelHandler.addFunctions(...)` currently loads the UDF class (already 
controlled by a ClassNameFilter allowlist/denylist) named in the model with the 
single-argument `Class.forName(className)`, which uses `initialize=true`. Only 
after the class object is returned do the shape-check helpers 
(`TableFunctionImpl.create`, `TableMacroImpl.create`, 
`ScalarFunctionImpl.create` / `functions`, `AggregateFunctionImpl.create`) 
decide whether the class is usable as a function, and if none of them accepts 
it, `addFunctions` throws `"Not a valid function class: ..."` at the end of the 
method. That ordering means the class's static initializer runs even when the 
class turns out to be the wrong shape, which can be avoided. This will keepĀ 
allowlist guarantee at "these classes may be used as functions", not "these 
classes' static initializers may be run at will".



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to