zhuqi-lucas opened a new issue, #23437:
URL: https://github.com/apache/datafusion/issues/23437
### Describe the bug
`information_schema.routines` and `SHOW FUNCTIONS` only enumerate scalar /
aggregate / window UDFs. Table functions (UDTFs) registered via
`SessionContext::register_udtf` are silently omitted, which makes them
undiscoverable through SQL.
### To Reproduce
\`\`\`rust
use datafusion::prelude::*;
use datafusion_catalog::TableFunctionImpl;
let ctx = SessionContext::new_with_config(
SessionConfig::new().with_information_schema(true),
);
ctx.register_udtf(\"my_udtf\", Arc::new(MyUdtf {}));
// Neither of these lists 'my_udtf':
ctx.sql(\"SHOW FUNCTIONS LIKE 'my%'\").await?.show().await?;
ctx.sql(\"SELECT * FROM information_schema.routines WHERE routine_name =
'my_udtf'\").await?.show().await?;
\`\`\`
### Expected behavior
UDTFs should appear in both `information_schema.routines` (with
`routine_type = 'FUNCTION'`, `function_type = 'TABLE'`, `data_type = 'TABLE'`)
and in `SHOW FUNCTIONS` output.
### Additional context
Root cause: `InformationSchemaConfig::make_routines` and `make_parameters`
iterate `udfs / udafs / udwfs` only. `TaskContext` doesn't expose
table_functions (and can't, since `TableFunction` lives in `datafusion-catalog`
which depends on `datafusion-execution`, so adding it to TaskContext would
create a cycle). The straightforward fix is to snapshot
`SessionState.table_functions` into `InformationSchemaProvider` at construction
time (the provider is built per-query via `schema_for_ref`, so the snapshot
stays fresh).
Additionally the current `SHOW FUNCTIONS` SQL rewrite does `parameters p
JOIN routines r` where `p` requires both an IN and an OUT parameter row. UDTFs
have no IN parameters, so they fall out of the JOIN. The fix rewrites the query
so it starts from OUT rows and LEFT JOINs IN rows.
PR: coming shortly.
--
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]