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

Add sql federation enumerable modify rule #28762

Merged
merged 9 commits into from
Oct 18, 2023

Conversation

zihaoAK47
Copy link
Member

Fixes #ISSUSE_ID.

Changes proposed in this pull request:

  • Change SQLFederationTable impl
  • Add enumerable modify rule
  • Add delete execution plan test case

Before committing this PR, I'm sure that I have checked the following options:

  • [ ✓] My code follows the code of conduct of this project.
  • [ ✓] I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • [ ✓] I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • [ ✓] I have added corresponding unit tests for my changes.


@Override
public Collection<Object[]> getModifiableCollection() {
return new LinkedList<>();
Copy link
Member

Choose a reason for hiding this comment

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

Why return empty list here?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the implementation of the getModifiableCollection method returns null, it will trigger a NullPointerException for the EnumerableTableModify class. However, for our implemented class EnumerableModify, it is allowed to return null and it should not call the getModifiableCollection method in its future implementations.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have changed the return type of this method.

# Conflicts:
#	kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/operator/physical/EnumerableModify.java
#	kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/planner/rule/converter/EnumerableModifyConverterRule.java
#	kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/planner/util/SQLFederationPlannerUtils.java
#	kernel/sql-federation/optimizer/src/test/resources/cases/federation-delete-sql-cases.xml
public RelNode convert(final RelNode rel) {
TableModify modify = (TableModify) rel;
ModifiableTable modifiableTable = modify.getTable().unwrap(ModifiableTable.class);
if (modifiableTable == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Please put null condition on the left side.


@Override
public Collection<Object[]> getModifiableCollection() {
return null;
Copy link
Member

Choose a reason for hiding this comment

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

If this method does not support now, can we throw UnsupportedOperationExcetion?

@Override
public Result implement(final EnumerableRelImplementor implementor, final Prefer prefer) {
// TODO generate delete statements based on the data set and related table information.
return null;
Copy link
Member

Choose a reason for hiding this comment

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

If this method does not support now, can we throw UnsupportedOperationExcetion?

Copy link
Member

@strongduanmu strongduanmu left a comment

Choose a reason for hiding this comment

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

Look great, merged.

@strongduanmu strongduanmu merged commit 7d94631 into apache:master Oct 18, 2023
133 checks passed
@zihaoAK47 zihaoAK47 deleted the dev_modify_rule branch October 18, 2023 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants