Skip to content

misc: Add python language in RoutineCharacteristics#26962

Merged
feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu:python_lang
Jan 14, 2026
Merged

misc: Add python language in RoutineCharacteristics#26962
feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu:python_lang

Conversation

@feilong-liu
Copy link
Copy Markdown
Contributor

Description

Language in RoutineCharacteristics represents the language used in the implementation of the functions. Currently it has SQL, JAVA and CPP. I am adding one more option, python, in this PR.

In addition, I also remove the constraint of only support CPP in the JsonFileBasedFunctionNamespaceManager.java. This check was added by me and it's because the JsonFileBasedFunctionNamespaceManager was intended to be used for registering CPP functions at that time. However, it's only a frontend for function registration, and has nothing to do the implementation of the functions to be registered, we do not need to limit us regarding the usage of it.

Motivation and Context

As in description.

Impact

As in description.

Test Plan

Easy change

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

@feilong-liu feilong-liu requested a review from a team as a code owner January 14, 2026 07:02
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Jan 14, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Jan 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds Python as a supported routine language and removes an overly strict constraint that limited JSON-file-based function registration to C++ UDFs only.

Class diagram for updated routine language support and JSON UDF namespace manager

classDiagram
    class RoutineCharacteristics {
    }

    class Language {
        +Language SQL
        +Language JAVA
        +Language CPP
        +Language PYTHON
        -String language
        +Language(String language)
        +String toString()
    }

    RoutineCharacteristics *-- Language : contains

    class JsonFileBasedFunctionNamespaceManager {
        -String catalogName
        +String getCatalogName()
        -void populateNameSpaceManager(UdfFunctionSignatureMap udfFunctionSignatureMap)
        -SqlInvokedFunction createSqlInvokedFunction(String functionName, JsonBasedUdfFunctionMetadata jsonBasedUdfFunctionMetaData)
    }

    class SqlInvokedFunction {
    }

    class UdfFunctionSignatureMap {
    }

    class JsonBasedUdfFunctionMetadata {
        +RoutineCharacteristics getRoutineCharacteristics()
        +String getSchema()
        +List~String~ getParamNames()
        +List~TypeSignature~ getParamTypes()
    }

    class RoutineCharacteristicsLanguage {
        +Language getLanguage()
    }

    JsonFileBasedFunctionNamespaceManager ..> SqlInvokedFunction : creates
    JsonFileBasedFunctionNamespaceManager ..> JsonBasedUdfFunctionMetadata : uses
    JsonBasedUdfFunctionMetadata ..> RoutineCharacteristicsLanguage : uses
    RoutineCharacteristicsLanguage ..> Language : returns
Loading

File-Level Changes

Change Details Files
Support Python as a routine language option.
  • Extend the RoutineCharacteristics.Language class with a new PYTHON constant
  • Ensure the new language identifier follows the existing pattern used for SQL, Java, and CPP
presto-spi/src/main/java/com/facebook/presto/spi/function/RoutineCharacteristics.java
Allow JsonFileBasedFunctionNamespaceManager to register UDFs implemented in languages other than C++.
  • Remove the state check that enforced CPP-only support when creating SqlInvokedFunction instances from JSON metadata
  • Rely on routine characteristics metadata without constraining the implementation language at this layer
presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/json/JsonFileBasedFunctionNamespaceManager.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The new PYTHON language constant uses all caps while JAVA is mixed-case ("Java"); consider aligning the string value with the existing convention or documenting the intended casing since this may affect serialization or equality checks.
  • With the removal of the checkState in JsonFileBasedFunctionNamespaceManager, it might be worth adding a more general validation/logging path to handle unsupported or unexpected RoutineCharacteristics.Language values during function registration rather than silently accepting them.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `PYTHON` language constant uses all caps while `JAVA` is mixed-case (`"Java"`); consider aligning the string value with the existing convention or documenting the intended casing since this may affect serialization or equality checks.
- With the removal of the `checkState` in `JsonFileBasedFunctionNamespaceManager`, it might be worth adding a more general validation/logging path to handle unsupported or unexpected `RoutineCharacteristics.Language` values during function registration rather than silently accepting them.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@feilong-liu feilong-liu merged commit 348c842 into prestodb:master Jan 14, 2026
85 of 87 checks passed
@feilong-liu feilong-liu deleted the python_lang branch January 14, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:Meta PR from Meta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants