Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Druid functions in INFORMATION_SCHEMA.ROUTINES table. #14378

Merged
merged 28 commits into from
Jun 13, 2023

Conversation

abhishekrb19
Copy link
Contributor

@abhishekrb19 abhishekrb19 commented Jun 6, 2023

This PR adds a new table INFORMATION_SCHEMA.ROUTINES. Resolves #14346.

Description

The implementation currently exposes information about all functions in INFORMATION_SCHEMA.ROUTINES. The table contains the following columns:

  • ROUTINE_CATALOG: Name of the database. Always set to druid.
  • ROUTINE_SCHEMA: Name of the schema. Always set to INFORMATION_SCHEMA.
  • ROUTINE_NAME: Name of the function or operator. E.g., APPROX_COUNT_DISTINCT_DS_THETA
  • ROUTINE_TYPE: Type of routine. Always set to FUNCTION.
  • IS_AGGREGATOR: Is the routine an aggregator or not. Returns YES for aggregator functions; NO for scalar functions.
  • SIGNATURES: Possible signatures for the routine as a string.

Since Calcite is the source of truth for all the registered functions, including ones loaded through custom extensions, the implementation uses the Calcite's operator table to extract this information at runtime.

A preview of the table from the Druid console:

CleanShot 2023-06-09 at 13 09 02@2x

Release note

Expose Druid functions via INFORMATION_SCHEMA.ROUTINES table.


Key changed/added classes in this PR
  • InformationSchema.java
  • DruidOperatorTable.java
  • InformationSchemaTest.java
  • DruidOperatorTableTest.java

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • been tested in a test Druid cluster.

@FrankChen021
Copy link
Member

I'm wondering why is not the IS_AGGREGATOR declared as BOOLEAN?

IMO for boolean type, it would be more simplier and intuitive for user to filter out aggregator functions like

select * from ROUTINES where IS_AGGREGATOR

@abhishekrb19
Copy link
Contributor Author

abhishekrb19 commented Jun 7, 2023

I'm wondering why is not the IS_AGGREGATOR declared as BOOLEAN?

IMO for boolean type, it would be more simplier and intuitive for user to filter out aggregator functions like

select * from ROUTINES where IS_AGGREGATOR

Good question, @FrankChen021. I wondered the same :)
The INFORMATION_SCHEMA tables in Druid already have boolean values converted to varchar - for example, IS_JOINABLE, IS_BROADCAST, IS_NULLABLE. The SQL spec notes that, so most standard implementations are just following the spec. So for consistency, I made the new column VARCHAR, as it doesn't deviate too much from the spec.

@FrankChen021
Copy link
Member

OK, let's keep it consistent with existing designs.

@abhishekrb19 abhishekrb19 marked this pull request as ready for review June 8, 2023 04:38
@zachjsh zachjsh self-requested a review June 12, 2023 15:01
Copy link
Contributor

@zachjsh zachjsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@zachjsh zachjsh merged commit b8495d4 into apache:master Jun 13, 2023
@abhishekagarwal87 abhishekagarwal87 added this to the 27.0 milestone Jul 19, 2023
@abhishekrb19 abhishekrb19 deleted the info_schema_routines branch August 3, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose Druid functions via INFORMATION_SCHEMA.ROUTINES table.
5 participants