Skip to content

Conversation

@reswqa
Copy link
Member

@reswqa reswqa commented May 1, 2023

Proposed changes

Issue Number: partially close #18505

Problem summary

Describe your changes.

Checklist(Required)

  • Does it affect the original behavior
  • Has unit tests been added
  • Has document been added or modified
  • Does it need to update dependencies
  • Is this PR support rollback (If NO, please explain WHY)

Further comments

  1. Support deleting only partial indices of partition.
  2. When the last index of a partition is deleted, delete this partition.

@github-actions github-actions bot added the area/planner Issues or PRs related to the query planner label May 1, 2023
@reswqa reswqa force-pushed the 185050-mv-lifecycle branch 2 times, most recently from 09820f6 to 5f00e43 Compare May 1, 2023 16:18
@dataroaring dataroaring changed the title [feat](mv lifecycle) Support drop partition from index. [feature-wip](mv lifecycle) Support drop partition from index. May 4, 2023
@reswqa reswqa force-pushed the 185050-mv-lifecycle branch from 5f00e43 to d91b65f Compare May 6, 2023 04:01
@reswqa
Copy link
Member Author

reswqa commented May 6, 2023

Thanks @dataroaring for the review.

I have updated this pull request in some new commits for the convenience of review, we can squashed them when merging code. Regression test is also modified to cover this changes. Please take a look in your free time, thanks~

@morrySnow
Copy link
Contributor

could we do select rollup/mv correctly after we do drop index partition?

@reswqa
Copy link
Member Author

reswqa commented May 6, 2023

could we do select rollup/mv correctly after we do drop index partition?

Sorry, I don't fully understand what you mean. Do you mean that after deleting baseIndex, can we still perform queries based on mv?

@dataroaring
Copy link
Contributor

run buildall

@morrySnow
Copy link
Contributor

could we do select rollup/mv correctly after we do drop index partition?

Sorry, I don't fully understand what you mean. Do you mean that after deleting baseIndex, can we still perform queries based on mv?

yes, i don't see any update about mv/rollup selection, so what' will happen when we have a table with mv and some partitions of mv have been dropped?

@reswqa
Copy link
Member Author

reswqa commented May 8, 2023

@morrySnow Good question. In this PR's implementation, only after all indexes of a partition are deleted will the partition be deleted (The effect is the same as the drop partition statement). As for only partial index were deleted:

  • If we only drop base Index and keep mv index for a specific partition, then queries that can hit mv can work correctly. This should be covered by the modified regression test in this PR as following:
     // drop base index.
     sql""" ALTER TABLE ${testTable} DROP PARTITION p1 FROM INDEX ${testTable} """
     explain {
       sql(" SELECT k1, k2+k3 FROM ${testTable} PARTITION(p1); ")
       contains "(${testMv})"
     }
     qt_select """ SELECT k1, k2+k3 FROM ${testTable} PARTITION(p1) """
  • If we only drop mv index for a specific partition. After checking the code, I found queries that can hit mv will indeed encounter some problems, such as NPE. Not sure if it requires significant changes to be compatible with this situation as I am not familiar with the selection algorithm of materialized view. If that's the case, I somehow tend to temporarily not support deleting non-based index through the Drop partition from index statement. One main reason is that our initial purpose in doing this work was to separate the lifecycle of mv and base table, so that the query can still be performed based on mv. WDYT?

If I missed something, please feel free to point me out 🙇. Also cc @dataroaring for the more advanced insights.

@reswqa reswqa force-pushed the 185050-mv-lifecycle branch from d91b65f to bd0db32 Compare May 17, 2023 10:33
@reswqa reswqa force-pushed the 185050-mv-lifecycle branch from bd0db32 to f054dec Compare May 17, 2023 10:38
@reswqa reswqa closed this Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/planner Issues or PRs related to the query planner kind/test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] separate life cycle of base table and its materialized views

3 participants