On Fri, Oct 23, 2020 at 2:35 PM Tom Lane wrote:
>
> "David G. Johnston" writes:
> > On Fri, Oct 23, 2020 at 8:47 AM Nikhil Benesch
> > wrote:
> >> Is there another option I'm missing? Would there be interest in
> >> extending split part so that negative indices counted from the end, as
> >> in:
On Fri, Oct 23, 2020 at 2:21 PM David G. Johnston
wrote:
> I'm torn here because this would be the first usage of this concept in
> PostgreSQL (I think).
Yeah, I also have some qualms about this design in the context of Postgres.
Particularly because Postgres allows arrays to begin at negative i
"David G. Johnston" writes:
> On Fri, Oct 23, 2020 at 8:47 AM Nikhil Benesch
> wrote:
>> Is there another option I'm missing? Would there be interest in
>> extending split part so that negative indices counted from the end, as
>> in:
>> split_part('foo bar baz', ' ', -1) -> 'baz'
> I'm torn
On Fri, Oct 23, 2020 at 8:47 AM Nikhil Benesch
wrote:
> Is there another option I'm missing? Would there be interest in
> extending split part so that negative indices counted from the end, as
> in:
>
> split_part('foo bar baz', ' ', -1) -> 'baz'
>
Some thoughts:
I'm torn here because this
Right, that's option 2 in my original mail. There are several
deficiencies with that idiom:
* It is non-obvious. Sure, it might make sense to you and I, but to
someone just learning SQL, it takes a minute to reason through why it
works. They're also unlikely to invent the trick on their own.
*
Hello,
reverse(split_part(reverse('foo bar baz'), ' ', 1)) -> 'baz'
Regards
- Mail original -
De: "Nikhil Benesch"
À: pgsql-general@lists.postgresql.org
Envoyé: Vendredi 23 Octobre 2020 17:47:16
Objet: split_part for the last element
Hi,
Suppose I need to split a string on a delim