Skip to content

Implement the POSITION function #8969

Closed

Description

@alamb

Is your feature request related to a problem or challenge?

The idea is to support the position function from postgres:

https://www.postgresql.org/docs/9.1/functions-string.html

position(substring in string)	

For example

postgres=# select position('world' in 'Helloworld');
 position
----------
        6
(1 row)

Describe the solution you'd like

As @zy-kkk points out on #8862 (comment) postgres has special syntax

To support the syntax position('world' in 'Helloworld') = 6 we probably need to do it in at https://github.com/sqlparser-rs/sqlparser-rs and add support for this syntax , which may be like adding the overlay function in apache/datafusion-sqlparser-rs#594.

Then we can change the datafusion planner to recognize that special syntax and call the instr function in #8862

Describe alternatives you've considered

No response

Additional context

This came up while implementing #8862

Activity

  1. alamb commented on Jan 23, 2024

    @alamb
    ContributorAuthor

    I think this is a good first issue, though it will require updating sqlparser-rs and then waiting for that to be released and making a change in datafusion

  2. Lordworms commented on Jan 23, 2024

    @Lordworms
    Contributor

    I would like to try that

  3. added a commit that references this issue on Jan 24, 2024
  4. Lordworms commented on Jan 24, 2024

    @Lordworms
    Contributor

    Hello, @alamb I have created a PR plz review it if you have time. Additionally, I have some other problems:

    1. what is the suitable resolution time for a picked-up issue?
    2. It might be slow and other problems may happen if I test the full test locally, may I create a PR first to test it?
    3. the rust-analyzer really consumes my CPU and RAM, is there any better way for a better Rust environment?
      I would appreciate so much for your answer
  5. alamb commented on Jan 25, 2024

    @alamb
    ContributorAuthor

    Hello, @alamb I have created a PR plz review it if you have time. Additionally, I have some other problems:

    Thank you @Lordworms - I have it on my

    1. what is the suitable resolution time for a picked-up issue?

    From my perspective there is no particular deadline for any issue.

    Instead, if someone is working on an issue but wasn't able to finish it before someone else needs / wants to work on the same thing, that other person can simply make a PR.

    I think most contributors are polite and check with the person who first signaled interest before working on something, but just because someone else might be working on something doesn't prevent anyone else from doing so

    1. It might be slow and other problems may happen if I test the full test locally, may I create a PR first to test it?

    I think making a draft PR to run the full suite of tests so you know which ones may need to run locally is a very reasonable strategy

    1. the rust-analyzer really consumes my CPU and RAM, is there any better way for a better Rust environment?
      I would appreciate so much for your answer

    I don't have a good answer for this -- Rust development environments in general do require significant resources

  6. Lordworms commented on Jan 25, 2024

    @Lordworms
    Contributor

    Thank you, got it!

  7. added 8 commits that reference this issue on Jan 25, 2024
  8. added a commit that references this issue on Feb 2, 2024
  9. SteveLauC commented on Feb 29, 2024

    @SteveLauC
    Contributor

    Seems that we should close this issue as it was completed in #8988

  10. alamb commented on Feb 29, 2024

    @alamb
    ContributorAuthor

    Seems that we should close this issue as it was completed in #8988

    Thank you @SteveLauC -- good call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions