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

Extend syntax for Dynamic Catalogs #22188

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ssheikin
Copy link
Contributor

@ssheikin ssheikin commented May 29, 2024

Description

  • Add ALTER CATALOG commands to change name, properties and owner with security checks
    RENAME, SET PROPERTIES implemented
    catalog owner is not supported yet.
    catalog comment is not supported yet.

Additional context and related issues

Trino epic #12709

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

# Section
* Add support for CREATE CATALOG LIKE statement. ({issue}`22188`)
* Add support for SHOW CREATE CATALOG statement. ({issue}`22188`)
* Add support for ALTER CATALOG RENAME statement. ({issue}`22188`)
* Add support for ALTER CATALOG SET PROPERTIES statement. ({issue}`22188`) 

@cla-bot cla-bot bot added the cla-signed label May 29, 2024
@ssheikin ssheikin changed the title Improve usability of Dynamic Catologs Extend syntax for Dynamic Catologs May 29, 2024
@ssheikin ssheikin changed the title Extend syntax for Dynamic Catologs Extend syntax for Dynamic Catalogs May 29, 2024
@ssheikin
Copy link
Contributor Author

ssheikin commented Jun 3, 2024

@martint @dain @kokosing @nineinchnick @SemionPar please review

@@ -155,6 +162,7 @@ statement
| EXPLAIN ANALYZE VERBOSE? statement #explainAnalyze
| SHOW CREATE TABLE qualifiedName #showCreateTable
| SHOW CREATE SCHEMA qualifiedName #showCreateSchema
| SHOW CREATE CATALOG identifier #showCreateCatalog
Copy link
Member

Choose a reason for hiding this comment

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

The current implementation exposes all properties even if it's marked as @ConfigHidden or @ConfigSecuritySensitive. I think we should hide or redact such properties.

Copy link
Member

Choose a reason for hiding this comment

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

@ssheikin could you maybe extract SHOW CREATE CATALOG to a separate PR? @martint would that help with getting the less controversial parts merged sooner?

Copy link
Member

Choose a reason for hiding this comment

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

I have removed SHOW CREATE CATALOG from this PR. It should be possible to re-add it once the following are merged:

I'm not sure if we want to introduce CREATE CATALOG LIKE (at least not at this stage). One question that comes to mind is how to define access rules for it. According to the SQL specification for CREATE TABLE LIKE:

If a <like clause> is contained in a <table definition>, then the applicable privileges for A shall include
SELECT privilege on the table identified in the <like clause>.

The issue is that we don’t have a SELECT privilege for catalogs.
I’m also not aware of any databases that provide CREATE ... LIKE functionality for anything other than tables. This makes it difficult to infer whether there’s a common approach we could adopt in this scenario.

Copy link

This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua

@github-actions github-actions bot added the stale label Jul 15, 2024
@mosabua
Copy link
Member

mosabua commented Jul 15, 2024

I am adding the stale-ignore label under the assumption that you are still driving this PR to completion @ssheikin

@mosabua mosabua added stale-ignore Use this label on PRs that should be ignored by the stale bot so they are not flagged or closed. and removed stale labels Jul 15, 2024
Comment on lines 57 to 61
Session session = stateMachine.getSession();

accessControl.checkCanRenameCatalog(session.toSecurityContext(), statement.getSource().getValue(), statement.getTarget().getValue());

catalogManager.renameCatalog(new CatalogName(statement.getSource().getValue()), new CatalogName(statement.getTarget().getValue()));
Copy link
Member

Choose a reason for hiding this comment

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

Did you omit lowercase intentionally?

trino> CREATE CATALOG test USING memory;
CREATE CATALOG
trino> ALTER CATALOG test RENAME TO TEST;
RENAME CATALOG
trino> show catalogs;
 Catalog
---------
 TEST
 memory
 system
 tpch
(4 rows)

Copy link
Member

Choose a reason for hiding this comment

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

I think it was unintentional. I updated it to match how other catalog statements work.

ssheikin and others added 2 commits January 2, 2025 12:47
@piotrrzysko piotrrzysko force-pushed the ssheikin/90/trino/dc branch from ee4ebe3 to 93954a1 Compare January 2, 2025 12:48
@piotrrzysko piotrrzysko force-pushed the ssheikin/90/trino/dc branch from 93954a1 to 315ed4d Compare January 6, 2025 20:09
@piotrrzysko
Copy link
Member

Current status of this PR: it will no longer include SHOW CREATE CATALOG and CREATE CATALOG LIKE. The former will likely be re-added once redacting security-sensitive information (#24563) is merged. The latter probably needs more discussion. I don’t have permissions to update the PR description. Could one of the maintainers or @ssheikin update it?

@kokosing
Copy link
Member

kokosing commented Jan 7, 2025

I have updated the description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed stale-ignore Use this label on PRs that should be ignored by the stale bot so they are not flagged or closed. syntax-needs-review
Development

Successfully merging this pull request may close these issues.

8 participants