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

feat: support temporary table #16250

Merged
merged 58 commits into from
Aug 22, 2024
Merged

Conversation

SkyFan2002
Copy link
Member

@SkyFan2002 SkyFan2002 commented Aug 14, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

This PR supports temporary table in mysql session.

  1. The Temporary table is only visible to the session that created it, and it will be automatically dropped when the session ends, with all data being vacuumed.
  2. Within a session, you can first create a Temporary table, then create a Normal Table with the same name; or you can first create a Normal Table, then create a Temporary table with the same name. In both scenarios, the Normal Table will be hidden by the Temporary table until the Temporary table is dropped.
  3. Creating a Temporary table and performing operations on it do not require any priviledges.

The syntex is:

CREATE [ OR REPLACE ] [ TRANSIENT | TEMPORARY | TEMP ] TABLE [ IF NOT EXISTS ] [ <database_name>. ]<table_name>
(
    <column_name> <data_type> [ NOT NULL | NULL ] 
                              [ { DEFAULT <expr> } ] 
                              [ AS (<expr>) STORED | VIRTUAL ]
                              [ COMMENT '<comment>' ],
    <column_name> <data_type> ...
    ...
)

Next step:

  1. Support in http handler
  2. Manually vacuum temporary table data that fails to be vacuumed automatically.
  3. system.temporary_tables

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Aug 14, 2024
@SkyFan2002 SkyFan2002 requested a review from TCeason August 20, 2024 17:02
# Conflicts:
#	src/query/service/src/interpreters/interpreter_table_create.rs
#	src/query/service/src/interpreters/interpreter_table_drop.rs
Copy link
Collaborator

@TCeason TCeason left a comment

Choose a reason for hiding this comment

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

Privilege part is LGTM

# Conflicts:
#	src/query/catalog/src/catalog/interface.rs
@BohuTANG
Copy link
Member

Conflicting files
src/query/service/src/sessions/session_ctx.rs

# Conflicts:
#	src/query/service/src/sessions/session_ctx.rs
Copy link
Member

@dantengsky dantengsky left a comment

Choose a reason for hiding this comment

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

LGTM 👍 supports the memory engine later? if it makes sense.

@dantengsky dantengsky added this pull request to the merge queue Aug 22, 2024
@SkyFan2002
Copy link
Member Author

LGTM 👍 supports the memory engine later? if it makes sense.

Got it.

@BohuTANG BohuTANG removed this pull request from the merge queue due to a manual request Aug 22, 2024
@BohuTANG BohuTANG merged commit 66c5f2e into databendlabs:main Aug 22, 2024
69 checks passed
@SkyFan2002 SkyFan2002 mentioned this pull request Aug 22, 2024
11 tasks
@wubx
Copy link
Member

wubx commented Oct 25, 2024

cc @soyeric128 need doc

@BohuTANG
Copy link
Member

cc @soyeric128 need doc

Not ready, there are still some tasks: #16310

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants