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

Broaden the types of indices that Table.slice supports #3130

Closed
2 tasks
chipkent opened this issue Nov 30, 2022 · 2 comments · Fixed by #4076
Closed
2 tasks

Broaden the types of indices that Table.slice supports #3130

chipkent opened this issue Nov 30, 2022 · 2 comments · Fixed by #4076
Assignees
Labels
core Core development tasks feature request New feature or request good first issue Good for newcomers query engine
Milestone

Comments

@chipkent
Copy link
Member

chipkent commented Nov 30, 2022

Table.slice() returns subsets of a table's rows based upon the i index of the rows. Slicing is allowed from the beginning or the end of the table.

As discussed in #3110 (comment), we should be supporting slices of the form x[-7:8], where the first slice index is negative, and the second slice index is positive (irstPositionInclusive < 0 && lastPositionExclusive > 0).

The documentation for the following need to be updated.

  • Java
  • Python
@rcaudy rcaudy modified the milestones: Backlog, Jan 2023 Nov 30, 2022
@pete-petey pete-petey modified the milestones: Jan 2023, Apr 2023 Apr 19, 2023
@rcaudy rcaudy modified the milestones: Apr 2023, Backlog May 31, 2023
@rcaudy rcaudy assigned malhotrashivam and unassigned rcaudy Jun 20, 2023
@rcaudy rcaudy added good first issue Good for newcomers core Core development tasks and removed triage labels Jun 20, 2023
@rcaudy rcaudy modified the milestones: Backlog, June 2023 Jun 20, 2023
@malhotrashivam
Copy link
Contributor

From what I understand, for the following input,

source = emptyTable(10).update("X=i")  // source = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
result = source.slice(-5, 9)

We should get result as rows [5, 6, 7, 8]

How should we handle a scenario like the following

source = emptyTable(10).update("X=i")  // source = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
result = source.slice(-5, 2)

Should we return an empty set or an exception?

For reference, in the current code, if we run the following

source = emptyTable(10).update("X=i")  // source = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
result = source.slice(7, -5)

We get an empty set []. So should we follow the same convention and return empty set in the slice(-5, 2) case?

@malhotrashivam
Copy link
Contributor

Python also returns an empty set, as shown in the following example

>>> x = list(range(10))     # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> x[7: -5]                # Returns []

So I am keeping the same behavior in our code too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core development tasks feature request New feature or request good first issue Good for newcomers query engine
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants