Skip to content

built-in function: Support locate(substr, str[, pos]) function #820

@jingchen2222

Description

@jingchen2222

Is your feature request related to a problem? Please describe.

locate(substr, str[, pos])

Returns the position of the first occurrence of substr in str after position pos. The given pos and return value are 1-based.

Examples:

> SELECT locate('bar', 'foobarbar');
 4
> SELECT locate('bar', 'foobarbar', 5);
 7

Reference:

https://spark.apache.org/docs/2.3.0/api/sql/#locate

Describe the solution you'd like

We do provide a built-in function development guide for you.
Please check OpenMLDB Build-In Function Develop Guide or the Chinese version for help.

Please make sure you:

  • Add built-in C++ function in src/udf/udf.h and src/udf/udf.cc
  • Register function to default library from function void DefaultUdfLibrary::IniStringUdf() in src/udf/default_udf_library.cc.
  • Add related unit test in src/codegen/udf_ir_builder_test.cc
  • Documenting function

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions