Repository navigation
Add LEFT() and RIGHT() SQL string functions - #2191
Merged
Merged
Conversation
Co-authored-by: mathiasrw <[email protected]>
Co-authored-by: mathiasrw <[email protected]>
Copilot
AI
changed the title
[WIP] Add RIGHT() and LEFT() SQL string functions
Add LEFT() and RIGHT() SQL string functions
Nov 19, 2025
mathiasrw
requested changes
Nov 19, 2025
Member
|
what happens if we got a user function called. left or. right? |
mathiasrw
marked this pull request as ready for review
November 19, 2025 12:25
mathiasrw
requested changes
Nov 19, 2025
- Case insensitivity tests (left, LEFT, Left, etc.) - Nested function tests (LEFT(RIGHT(...)), RIGHT(LEFT(...))) - Complex nesting with multiple functions - Integration with UPPER/LOWER functions - Integration with CONCAT function - Special characters handling - User-defined function compatibility test Co-authored-by: mathiasrw <[email protected]>
Contributor
Author
User-defined functions work alongside the built-in LEFT and RIGHT functions. The built-in stdlib functions (LEFT, RIGHT) are checked first, so they take precedence. If you want to define a custom function, you'd need to use a different name like Test case 17 demonstrates this - a custom Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
mathiasrw
approved these changes
Nov 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements LEFT() and RIGHT() string functions from standard SQL. These were previously unavailable because LEFT and RIGHT are reserved keywords for join operations.
Changes
Parser (
src/alasqlparser.jison)Functions (
src/55functions.js)stdlib.LEFT(string, length)- returns leftmost N characters usingsubstr(0, length)stdlib.RIGHT(string, length)- returns rightmost N characters usingsubstr(string.length - length)Tests (
test/test590.js)Example Usage
Both functions handle undefined values gracefully and follow the same patterns as existing string functions (SUBSTRING, UPPER, LOWER, etc.). User-defined functions with different names can coexist with the built-in LEFT and RIGHT functions.
Original prompt
<issue_description>Add RIGHT() and LEFT() string functions from SQL
Spawned from #588
</issue_description>
<agent_instructions>Please make a test file called test590.js verifying if this issue is still a problem.
If it is a problem try to solve it.
If you need to update the grammar of alasql, then please do small precice changes to alasqlparser.jison and then run
yarn jison && yarn testtake special care with the danger mentioned in the last message in the conversation</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@mathiasrw Yep. Still relevant. @mathiasrw Yes.You will need to add the keywords specificly as part of acceptable function names, this way it becomes valid to have those tokens as function names instead of just strings (right now the token LEFT will only be acceptable in relation to join)</comment_new>
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.