Skip to content

update string function docs and add a concat page - #7718

Merged
philrz merged 1 commit into
mainfrom
docs-string-functions
Nov 24, 2026
Merged

philrz merged 1 commit into
mainfrom
docs-string-functions

Conversation

@philrz

@philrz philrz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

This is the second PR from the pass over the function docs (after #7714), checking each Strings page against what super does on current main.

  • concat: new page. The function was added in Add concat function, drop "+" for string concatenation #6486 but never got one. The || page now links to it.
  • grep: added the missing comma in the synopsis. The NOTE still described glob patterns, so it now says what a pattern does today: one that can match only one fixed string (e.g., one with no regular expression metacharacters) is a case-insensitive substring search, as in a keyword search, and any other regular expression is case-sensitive unless it starts with (?i). Added an example of each.
  • join: the separator is optional (join(["a","b"]) is "ab"). Updated the synopsis and added an example.
  • position: said that the synopsis's position(sub IN s) form is SQL syntax that works in pipe queries too, and that the result is 1-based whatever the index_base pragma is set to. Added examples of the SQL form and of 0 for not found.
  • substring: said that at least one of FROM and FOR is required, what each defaults to, and that a negative start counts back from the end, with an example. Also fixed an example title.

Two questions for @mccanne before this merges:

  1. Is the grep behavior in the new NOTE intended? grep still seems to be doing case insensitive substring searches #6200 asked this after simplify regexp/grep syntax #6115 said that grep now uses only regular expressions. If it is, this PR documents it and grep still seems to be doing case insensitive substring searches #6200 can be closed. If not, I'll drop the NOTE's first sentence and the new example, and we can discuss changing how grep handles these patterns. Related: when the pattern isn't a constant (e.g., grep(p, this) with p from the input), it's always a case-insensitive substring search, even with metacharacters, so a p of "foo|baz" doesn't match "baz". The page avoids this by not mentioning computed patterns, but let me know if you think we should address it.
  2. Should position obey the index_base pragma? substring (Make substring obey pragma index_base #6351) and slices do, so with the default 0-based setting, substring(s FROM position(s, 'bar')) on "foobar" gives "ar". The page now says position is always 1-based, as it is today. I'm planning a small follow-on PR anyway to make position count characters instead of bytes (position("éébar", "bar") is 5, where Postgres and DuckDB give 3), so if the answer is yes, that PR can make this change too and update the page.

Add a page for concat(), which had none.  Replace grep's stale NOTE
about glob patterns with how its patterns match today, and document
join's optional separator, position's SQL syntax and 1-based result,
and substring's defaults and negative start.
@philrz philrz self-assigned this Nov 24, 2026
@philrz
philrz requested review from a team and mccanne November 24, 2026 20:43
@mccanne

mccanne commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator
  1. let's address
  2. we should match sql semantics and don't necessarily need to follow pragme

@philrz

philrz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @mccanne! Based on your comment, I'll merge this as is, since it matches what super does today. Then:

  1. I'll open a PR that makes grep always treat its pattern as a regular expression, as simplify regexp/grep syntax #6115 said it would: case-sensitive unless it starts with (?i), whether the pattern is a constant or computed. That PR will update this NOTE and close grep still seems to be doing case insensitive substring searches #6200. (If you'd rather keep plain-string patterns case-insensitive like a keyword search, I'll instead make computed patterns behave the way constant ones do now.)
  2. position stays 1-based whatever index_base is, as the page now says. The follow-on PR will make it count characters instead of bytes, to match SQL.

@philrz
philrz merged commit 14a07c1 into main Nov 24, 2026
4 checks passed
@philrz
philrz deleted the docs-string-functions branch November 24, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants