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

Fix failure when creating a schema with non-lowercase username on Iceberg Glue catalog #16124

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

ebyhr
Copy link
Member

@ebyhr ebyhr commented Feb 15, 2023

Description

Don't lowercase name in TrinoPrincipal when PrincipalType is USER.
Fixes #16116

Release notes

(x) Release notes are required, with the following suggested text:

# Iceberg
* Fix failure when creating a schema with a username containing uppercase characters on Iceberg Glue catalog. ({issue}`16116`)

@cla-bot cla-bot bot added the cla-signed label Feb 15, 2023
@ebyhr ebyhr force-pushed the ebi/trino-principal branch from 35c3f64 to c251041 Compare February 15, 2023 11:54
@ebyhr ebyhr changed the title Don't lowercase name in TrinoPrincipal Don't lowercase name in TrinoPrincipal when PrincipalType is USER Feb 15, 2023
@ebyhr ebyhr force-pushed the ebi/trino-principal branch 2 times, most recently from f061439 to 7dd6bc9 Compare February 15, 2023 23:10
@ebyhr ebyhr marked this pull request as ready for review February 15, 2023 23:11
@ebyhr
Copy link
Member Author

ebyhr commented Feb 16, 2023

CI hit #16137

@ebyhr ebyhr requested review from kokosing and krvikash February 16, 2023 09:53
Copy link
Contributor

@krvikash krvikash left a comment

Choose a reason for hiding this comment

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

LGTM.
Fixes https://github.com/trinodb/trino/issues/16116 in the description.

@ebyhr ebyhr self-assigned this Feb 19, 2023
@ebyhr ebyhr requested a review from dain February 20, 2023 23:20
@dain dain requested a review from martint February 21, 2023 17:45
@dain
Copy link
Member

dain commented Feb 21, 2023

I'm not sure of the impact of this change, and this impacts security commands, so I'm not comfortable approving right now.

The USER string is an identifier in SQL, and I believe these have canonicalization rules covered by the SQL spec. I believe Trino is adding support for this in some cases, and this change should be in line with the other changes, so I added @martint as a reviewer.

@dain dain removed their request for review February 21, 2023 17:49
@martint
Copy link
Member

martint commented Feb 24, 2023

Per the SQL spec, identifiers should only be canonicalized (to upper-case) when they are not "delimited" (i.e., in double quotes). Obviously, making such a change wholesale would break compatibility. Also, many systems have different rules. Therefore, the plan so far is to let plugins decide how to canonicalize identifiers (schemas, tables, columns, users, roles, etc) before the values are used in other connector/plugin API calls.

The change proposed in this PR, as it stands, may break compatibility for plugins that are case-insensitive.

@electrum
Copy link
Member

Should we instead fix this for Glue by lowercasing the name in TrinoGlueCatalog?

@ebyhr ebyhr force-pushed the ebi/trino-principal branch from 7dd6bc9 to 470794e Compare February 24, 2023 23:10
@ebyhr ebyhr changed the title Don't lowercase name in TrinoPrincipal when PrincipalType is USER Fix failure when creating a schema with non-lowercase usrename on Iceberg Glue catalog Feb 24, 2023
@ebyhr ebyhr requested a review from electrum February 24, 2023 23:27
@findinpath
Copy link
Contributor

@ebyhr can you pls rebase to address the conflicts?

@ebyhr ebyhr force-pushed the ebi/trino-principal branch from 470794e to b58927e Compare March 10, 2023 11:07
@github-actions github-actions bot added the iceberg Iceberg connector label Mar 10, 2023
@krvikash
Copy link
Contributor

Hi @ebyhr, Is anything remaining in this PR?

@ebyhr ebyhr requested a review from findepi March 17, 2023 04:43
@@ -253,7 +253,7 @@ public Optional<TrinoPrincipal> getNamespacePrincipal(ConnectorSession session,
public void createNamespace(ConnectorSession session, String namespace, Map<String, Object> properties, TrinoPrincipal owner)
{
checkArgument(owner.getType() == PrincipalType.USER, "Owner type must be USER");
checkArgument(owner.getName().equals(session.getUser()), "Explicit schema owner is not supported");
checkArgument(owner.getName().equalsIgnoreCase(session.getUser()), "Explicit schema owner is not supported");
Copy link
Member

Choose a reason for hiding this comment

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

why would owner name get lowercased?

why not compare equality with session.getUser().toLower?

public void testCreateSchemaWithNonLowercaseOwnerName()
{
Session newSession = Session.builder(getSession())
.setIdentity(Identity.ofUser("User"))
Copy link
Member

Choose a reason for hiding this comment

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

Should we have a reusable (connector) (smoke) test?

@ebyhr ebyhr force-pushed the ebi/trino-principal branch 2 times, most recently from bbe5ebf to 1e189a8 Compare March 20, 2023 22:24
@ebyhr ebyhr changed the title Fix failure when creating a schema with non-lowercase usrename on Iceberg Glue catalog Fix failure when creating a schema with non-lowercase username on Iceberg Glue catalog Mar 24, 2023
@ebyhr ebyhr force-pushed the ebi/trino-principal branch from 1e189a8 to 03b6dc1 Compare March 27, 2023 00:37
@github-actions github-actions bot added hive Hive connector tests:hive labels Mar 27, 2023
@ebyhr ebyhr force-pushed the ebi/trino-principal branch from 03b6dc1 to 2576094 Compare March 27, 2023 10:11
@ebyhr
Copy link
Member Author

ebyhr commented Mar 29, 2023

/test-with-secrets sha=25760946b0a17393dcf1f1f6cdc0a6bda3fce2f4

@github-actions
Copy link

The CI workflow run with tests that require additional secrets finished as failure: https://github.com/trinodb/trino/actions/runs/4550668692

TrinoPrincipal sets the owner name in lowercase.
@ebyhr ebyhr force-pushed the ebi/trino-principal branch from 2576094 to b2f71c2 Compare March 30, 2023 09:34
@ebyhr
Copy link
Member Author

ebyhr commented Mar 30, 2023

/test-with-secrets sha=b2f71c2b30a4ca8ef1b38baca593b3867352b405

@github-actions
Copy link

The CI workflow run with tests that require additional secrets finished as failure: https://github.com/trinodb/trino/actions/runs/4565827240

@ebyhr ebyhr merged commit bb4294b into trinodb:master Apr 6, 2023
@ebyhr ebyhr deleted the ebi/trino-principal branch April 6, 2023 22:43
@github-actions github-actions bot added this to the 413 milestone Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed hive Hive connector iceberg Iceberg connector
7 participants