Skip to content

Conversation

@KKould
Copy link
Member

@KKould KKould commented Oct 14, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

External UDF supports passing STAGE_LOCATION as a parameter

This PR introduces a new DataType::StageLocation for passing STAGE_LOCATION
When resolving_udf_server, the parameters of type StageLocation are collected and passed to databend_udf as the value of Header: databend-stage-mapping (StageLocation is not passed as a parameter to UDF).
databendlabs/databend-udf#14

Added Expr::StageLocation for passing StageLocation as a Function parameter

Example:

CREATE OR REPLACE FUNCTION gcd (
    stage_loc STAGE_LOCATION,
    a INT,
    b INT
)
RETURNS INT
LANGUAGE python
HANDLER = 'gcd'
ADDRESS = 'http://127.0.0.1:8815';

SELECT gcd(@gcd_stage/input/2024/, 21, 14);

udf_server example

@udf(stage_refs=["stage_loc"], input_types=["INT"], result_type="INT")
def gcd(stage: StageLocation, value):
    bucket_cfg = stage.storage
    working_path = stage.relative_path
    ...

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Oct 14, 2025
@KKould KKould marked this pull request as ready for review October 14, 2025 17:35
@KKould KKould requested a review from drmingdrmer as a code owner October 14, 2025 17:35
@KKould KKould requested a review from BohuTANG October 14, 2025 17:35
@KKould KKould self-assigned this Oct 14, 2025
@KKould KKould requested a review from sundy-li October 15, 2025 07:03
Copy link
Member

@BohuTANG BohuTANG left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

@drmingdrmer reviewed 21 of 50 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: 22 of 50 files reviewed, all discussions resolved (waiting on @sundy-li)

@KKould KKould merged commit a7973fd into databendlabs:main Oct 15, 2025
168 of 171 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants