justinmclean opened a new issue, #10226:
URL: https://github.com/apache/gravitino/issues/10226

   ### What would you like to be improved?
   
   FunctionEntity.Builder.build() calls validate(), which relies on fields(). 
In FunctionEntity, fields() omits namespace, so a function can be built with a 
null namespace without immediate validation failure.
   
   ### How should we improve?
   
   Include namespace as a required field in FunctionEntity validation, then add 
it to fields() so build() fails when namespace is missing.
   
   Here a unit test for that:
   ```
   
     @Test
     public void testBuildShouldFailWhenNamespaceIsMissing() {
       FunctionParam param = FunctionParams.of("param1", 
Types.IntegerType.get());
       FunctionImpl impl = FunctionImpls.ofSql(FunctionImpl.RuntimeType.SPARK, 
"SELECT param1 + 1");
       FunctionDefinition definition =
           FunctionDefinitions.of(
               new FunctionParam[] {param}, Types.IntegerType.get(), new 
FunctionImpl[] {impl});
       AuditInfo auditInfo = 
AuditInfo.builder().withCreator("tester").withCreateTime(Instant.now()).build();
   
       assertThrows(
           IllegalArgumentException.class,
           () ->
               FunctionEntity.builder()
                   .withId(1L)
                   .withName("f")
                   .withComment("test")
                   .withFunctionType(FunctionType.SCALAR)
                   .withDeterministic(true)
                   .withDefinitions(new FunctionDefinition[] {definition})
                   .withAuditInfo(auditInfo)
                   .build());
     }
   ```


-- 
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]

Reply via email to