Skip to content

Commit

Permalink
change comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jackylee-ch committed Apr 14, 2024
1 parent 01ecc1e commit 926b2e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
11 changes: 4 additions & 7 deletions velox/docs/functions/spark/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,18 @@ Unless specified otherwise, all functions return NULL if at least one of the arg

SELECT rtrim('kr', 'spark'); -- "spa"

.. spark:function:: split(string, regex) -> array(string)
.. spark:function:: split(string, delimiter) -> array(string)
Returns an array by splitting ``string`` as many times as possible.
The delimiter is any string matching regex, supported by re2.
This is equivalent to split(string, regex, -1), -1 is used for limit. ::
Splits ``string`` on ``delimiter`` and returns an array. ::

SELECT split('oneAtwoBthreeC', '[ABC]'); -- ["one","two","three",""]
SELECT split('one', ''); -- ["o", "n", "e", ""]
SELECT split('one', '1'); -- ["one"]

.. spark:function:: split(string, regex, limit) -> array(string)
.. spark:function:: split(string, delimiter, limit) -> array(string)
:noindex:

Splits ``string`` on ``regex`` and returns an array of size at most ``limit``.
If limit is negative, ``string`` will be split as many times as possible. ::
Splits ``string`` on ``delimiter`` and returns an array of size at most ``limit``. ::

SELECT split('oneAtwoBthreeC', '[ABC]', -1); -- ["one","two","three",""]
SELECT split('oneAtwoBthreeC', '[ABC]', 0); -- ["one", "two", "three", ""]
Expand Down
3 changes: 1 addition & 2 deletions velox/functions/lib/Re2Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ void re2SplitAll(
const re2::StringPiece remaining = input.substr(pos);
arrayWriter.add_item().setNoCopy(
StringView(remaining.data(), remaining.size()));
} else if (pos == input.size()) {
} else {
arrayWriter.add_item().setNoCopy(StringView(nullptr, 0));
}

Expand Down Expand Up @@ -2059,5 +2059,4 @@ std::vector<std::shared_ptr<exec::FunctionSignature>> re2SplitAllSignatures() {
.build(),
};
}

} // namespace facebook::velox::functions

0 comments on commit 926b2e9

Please sign in to comment.