Skip to content

SHOW FUNCTIONS / information_schema.routines omit table functions (UDTFs) #23437

Description

@zhuqi-lucas

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions