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

[SPARK-39966][SQL] Use V2 Filter in SupportsDelete #37393

Closed
wants to merge 9 commits into from

Conversation

huaxingao
Copy link
Contributor

What changes were proposed in this pull request?

Migrate SupportsDelete to use V2 Filter

Why are the changes needed?

this is part of the V2Filter migration work

Does this PR introduce any user-facing change?

Yes
add SupportsDeleteV2

How was this patch tested?

new tests

@github-actions github-actions bot added the SQL label Aug 3, 2022
@huaxingao
Copy link
Contributor Author

cc @cloud-fan

@huaxingao
Copy link
Contributor Author

@cloud-fan Could you check one more time, please?

The test failure is not relevant.

def filtersToKeys(
keys: Iterable[Seq[Any]],
partitionNames: Seq[String],
filters: Array[Filter]): Iterable[Seq[Any]] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is currently used by class Overwrite(filters: Array[Filter]) at line 422, so I will leave this method in this base class for now. When I work on my next PR SupportsOverWriteV2, I will clean up this base class, move this method and all the Filter related methods to InMemoryTable.


def toV1(
predicates: Array[Predicate],
skipIfNotConvertible: Boolean): Array[Filter] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

thinking about this more, I think we can just have

def toV1(predicates: Array[Predicate]): Array[Filter] = ...

In SupportsDelete, we can check the number of returned v1 filter

  default boolean canDeleteWhere(Predicate[] predicates) {
    Filter[] v1Filters = PredicateUtils.toV1(predicates);
    if (v1Filters.length < predicates) return false;
    return this.canDeleteWhere(v1Filters);
  }


  default void deleteWhere(Predicate[] predicates) {
    this.deleteWhere(PredicateUtils.toV1(predicates));
  }

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 actually have thought about this, this works OK for SupportsDelete, but we will have to throw Exception later on for SupportsOverwrite, because we don't have an API canOverwrite.

Copy link
Contributor

Choose a reason for hiding this comment

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

shall we add canOverwrite?

Copy link
Contributor

Choose a reason for hiding this comment

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

at least we can still throw error if we want to, by checking the number of returned v1 filters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NVM, I will change to this way, and check if (v1Filters.length < predicates.length) and throw Exception in SupportsOverwrite.overwrite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replied without seeing your previous message.

Will add canOverwrite

@huaxingao huaxingao closed this in 9dff034 Aug 11, 2022
@huaxingao
Copy link
Contributor Author

Merged to master. Thanks @cloud-fan @beliefer @LuciferYang for reviewing!

@huaxingao huaxingao deleted the v2delete branch August 11, 2022 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants