diqiu50 opened a new issue, #13139:
URL: https://github.com/apache/gravitino/issues/13139
### Version
main branch
### Describe what's wrong
Registering a SQL/TRINO function whose `sql` field holds the body, e.g.
`fn_double(n integer) RETURNS integer` with `sql = n * 2`, makes every function
in that schema unlistable and uncallable from Trino.
`GravitinoMetadata.toLanguageFunctions` passes the stored body straight into
`LanguageFunction`, but Trino parses that string with
`standaloneFunctionSpecification`, which requires a complete `FUNCTION
name(params) RETURNS type ... RETURN body` routine.
`LanguageFunctionManager.listFunctions` parses every entry, so one function
breaks the whole schema; `getLanguageFunctions` goes through the same
conversion, so invocation fails too.
### Error message and/or stacktrace
```
Query failed: line 1:1: mismatched input "n". Expecting: "FUNCTION"
io.trino.sql.parser.ParsingException
at io.trino.sql.parser.SqlParser.createFunctionSpecification
at
io.trino.metadata.LanguageFunctionManager.listFunctions(LanguageFunctionManager.java:179)
at io.trino.metadata.MetadataManager.listFunctions
at io.trino.sql.rewrite.ShowQueriesRewrite$Visitor.visitShowFunctions
```
### How to reproduce
1. Register a function with `{"language":"SQL","runtime":"TRINO","sql":"n *
2"}`.
2. In Trino: `SHOW FUNCTIONS FROM <catalog>.<schema>` or `SELECT
<catalog>.<schema>.fn_double(21)`.
### Additional context
The connector should assemble the full specification from the function name,
parameters and return type before constructing the `LanguageFunction`.
--
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]