Rewrite `SHOW FUNCTIONS` to another SQL query The query is based on the `information_schema.routines` and `information_schema.parameters` tables The output columns: - function_name: The name of function - return_type: The return type of the function - parameters: The name of parameters (ordered by the ordinal position) - parameter_types: The type of parameters (ordered by the ordinal position) -
(
&self,
filter: Option<ShowStatementFilter>,
)
| 2560 | /// - description: The description of the function (the description defined in the document) |
| 2561 | /// - syntax_example: The syntax_example of the function (the syntax_example defined in the document) |
| 2562 | fn show_functions_to_plan( |
| 2563 | &self, |
| 2564 | filter: Option<ShowStatementFilter>, |
| 2565 | ) -> Result<LogicalPlan> { |
| 2566 | let where_clause = if let Some(filter) = filter { |
| 2567 | match filter { |
| 2568 | ShowStatementFilter::Like(like) => { |
| 2569 | format!("WHERE p.function_name like '{like}'") |
| 2570 | } |
| 2571 | _ => return plan_err!("Unsupported SHOW FUNCTIONS filter"), |
| 2572 | } |
| 2573 | } else { |
| 2574 | "".to_string() |
| 2575 | }; |
| 2576 | |
| 2577 | let query = format!( |
| 2578 | r#" |
| 2579 | SELECT DISTINCT |
| 2580 | p.*, |
| 2581 | r.function_type function_type, |
| 2582 | r.description description, |
| 2583 | r.syntax_example syntax_example |
| 2584 | FROM |
| 2585 | ( |
| 2586 | SELECT |
| 2587 | i.specific_name function_name, |
| 2588 | o.data_type return_type, |
| 2589 | array_agg(i.parameter_name ORDER BY i.ordinal_position ASC) parameters, |
| 2590 | array_agg(i.data_type ORDER BY i.ordinal_position ASC) parameter_types |
| 2591 | FROM ( |
| 2592 | SELECT |
| 2593 | specific_catalog, |
| 2594 | specific_schema, |
| 2595 | specific_name, |
| 2596 | ordinal_position, |
| 2597 | parameter_name, |
| 2598 | data_type, |
| 2599 | rid |
| 2600 | FROM |
| 2601 | information_schema.parameters |
| 2602 | WHERE |
| 2603 | parameter_mode = 'IN' |
| 2604 | ) i |
| 2605 | JOIN |
| 2606 | ( |
| 2607 | SELECT |
| 2608 | specific_catalog, |
| 2609 | specific_schema, |
| 2610 | specific_name, |
| 2611 | ordinal_position, |
| 2612 | parameter_name, |
| 2613 | data_type, |
| 2614 | rid |
| 2615 | FROM |
| 2616 | information_schema.parameters |
| 2617 | WHERE |
| 2618 | parameter_mode = 'OUT' |
| 2619 | ) o |
no test coverage detected