Skip to content

Add scalar function call methods to SQLExpressions for schema-qualified function names #1657

Description

@zio0911
  • I am willing to put in the work and submit a PR to resolve this issue.

Is your feature request related to a problem?

When calling scalar functions with fully qualified names (e.g., cross-database function calls in MSSQL like other_db.dbo.my_function(arg1, arg2)), there is no convenient API in SQLExpressions.

Currently, the only option is to manually construct template strings with positional placeholders:

Expressions.stringTemplate("other_db.dbo.my_function({0}, {1}, {2})", arg1, arg2, arg3);

RelationalFunctionCall exists but is designed for table-valued functions in FROM/JOIN clauses, not for scalar contexts (SELECT, WHERE, INSERT VALUES).

Describe the solution you'd like

Add scalar function call factory methods to SQLExpressions:

// Generic
SQLExpressions.function(String.class, "other_db.dbo.my_function", arg1, arg2);

// String-returning
SQLExpressions.stringFunction("other_db.dbo.my_function", arg1, arg2);

// Number-returning
SQLExpressions.numberFunction(Integer.class, "dbo.calculate", arg1);

The function name would be passed through as-is, supporting:

  • my_function(...) - simple
  • schema.my_function(...) - 2-part
  • database.schema.my_function(...) - 3-part (cross-database)
  • server.database.schema.my_function(...) - 4-part (linked server)

Additional context

I have an implementation ready and can submit a PR if this approach is acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions