Introduce INFORMATION_SCHEMA.ROUTINES table#13255
Conversation
|
There is another useful column I wanted to add, However, I think we don't have enough information in the function signature to do it 🤔 . |
| query TTTTTTTBTTT rowsort | ||
| select * from information_schema.routines where routine_name = 'date_trunc' OR routine_name = 'string_agg' OR routine_name = 'rank'; | ||
| ---- | ||
| datafusion public date_trunc datafusion public date_trunc FUNCTION true Timestamp(Microsecond, None) SCALAR Truncates a timestamp value to a specified precision. |
There was a problem hiding this comment.
The type name is an ArrowType name, e.g., Timestamp (Microsecond, None). I prefer to return a SQL type. I think it would be improved if we finished the logical type epic.
| // TODO: Implement for other types | ||
| TypeSignature::Uniform(_, _) | ||
| | TypeSignature::Coercible(_) |
There was a problem hiding this comment.
There is a follow-up issue for inferring the types from other TypeSignatures.
There was a problem hiding this comment.
I think we should file a ticket to track adding the feature (I bet some other contributors would enjoy helping out now that you have setup the framework)
| // only handle the function which implemented [`ScalarUDFImpl::return_type`] method | ||
| let return_type = udf.return_type(&arg_types).ok().map(|t| t.to_string()); |
There was a problem hiding this comment.
Some functions only implement return_type_from_exprs, e.g., arrow_cast. It's hard to get the return type here. Return null for this case.
alamb
left a comment
There was a problem hiding this comment.
Looks like a great start to me -- thank you @goldmedal
I think it would be really nice to file tickets for the follow on work you have identified so we don't forget (and so that others can help out)
| // TODO: Implement for other types | ||
| TypeSignature::Uniform(_, _) | ||
| | TypeSignature::Coercible(_) |
There was a problem hiding this comment.
I think we should file a ticket to track adding the feature (I bet some other contributors would enjoy helping out now that you have setup the framework)
| query TTTTTTTBTTT rowsort | ||
| select * from information_schema.routines where routine_name = 'date_trunc' OR routine_name = 'string_agg' OR routine_name = 'rank'; | ||
| ---- | ||
| datafusion public date_trunc datafusion public date_trunc FUNCTION true Timestamp(Microsecond, None) SCALAR Truncates a timestamp value to a specified precision. |
|
fyi @findepi |
|
Thanks @alamb for reviewing |
* tmp * introduce routines table * add is_deterministic field * cargo fmt * rollback the session_state changed
You are correct, there isn't a way to do it currently without inspecting the code. |
Which issue does this PR close?
Part of #12144 .
Rationale for this change
As per the discussed in #12144 (comment), to support listing available functions, we should implement corresponding tables in the information schema.
What changes are included in this PR?
Refer to Postgres, MySQL, and BigQuery, I implemented the following columns for the
ROUTINEStable:FUNCTION(this field could bePROCEDUREin other databases)Immutablescalar,aggregateorwindowAre these changes tested?
yes
Are there any user-facing changes?
A new table of information_schema