Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SLICE function #1340

Merged
merged 17 commits into from Aug 16, 2023
Merged

Implement SLICE function #1340

merged 17 commits into from Aug 16, 2023

Conversation

Kwontaehwon
Copy link
Contributor

@Kwontaehwon Kwontaehwon commented Jul 28, 2023

resolved #1307

Description

Implement SLICE function that return subsets of list.
Support both positive and negative start value

  • If start value over the list length, it returns empty list : []
INSERT INTO Test VALUES ('[1,2,3,4]');
SELECT SLICE(list, 100, 5) AS value FROM Test;
  • If start value is negative and its absolute value is over the list length, it convert to index 0.

Example

SLICE(<list>, <start>, <length>)

@panarch panarch added the enhancement New feature or request label Jul 28, 2023
@coveralls
Copy link

coveralls commented Jul 28, 2023

Pull Request Test Coverage Report for Build 5867995917

  • 165 of 165 (100.0%) changed or added relevant lines in 6 files are covered.
  • 34 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.06%) to 99.143%

Files with Coverage Reduction New Missed Lines %
core/src/executor/validate.rs 1 99.24%
core/src/executor/evaluate/mod.rs 3 99.36%
core/src/executor/aggregate/mod.rs 30 84.21%
Totals Coverage Status
Change from base Build 5857086559: -0.06%
Covered Lines: 48465
Relevant Lines: 48884

💛 - Coveralls

}
if start < 0 {
start = 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really good! The slice function will soon become a new feature. It would be nice if only very small changes were possible. Couldn't these parts be put together?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended that when a negative index is given, if index remain negative even after adding the size of vector to convert it to a positive index, it falls outside the range of vector. So I change index to 0.

@panarch panarch requested a review from zmrdltl August 7, 2023 14:25
Copy link
Member

@panarch panarch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all great!
after the small conflict has been resolved, then let's ship this to the main!

@panarch panarch merged commit ce5e930 into gluesql:main Aug 16, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement SLICE function
4 participants