Skip to content

Correct exception type when table exists while creating a view#15580

Closed
krvikash wants to merge 1 commit intotrinodb:masterfrom
krvikash:fix-error-message-when-table-exists-while-creating-view
Closed

Correct exception type when table exists while creating a view#15580
krvikash wants to merge 1 commit intotrinodb:masterfrom
krvikash:fix-error-message-when-table-exists-while-creating-view

Conversation

@krvikash
Copy link
Copy Markdown
Contributor

@krvikash krvikash commented Jan 3, 2023

Description

ViewAlreadyExistsException exception is misleading when a table exists while creating a view. Changing it to TableAlreadyExistsException.

Release notes

(X) This is not user-visible or docs only and no release notes are required.

@cla-bot cla-bot bot added the cla-signed label Jan 3, 2023
@krvikash krvikash added the no-release-notes This pull request does not require release notes entry label Jan 3, 2023
@krvikash krvikash force-pushed the fix-error-message-when-table-exists-while-creating-view branch 2 times, most recently from 785bfd4 to 8451595 Compare January 3, 2023 15:21
@krvikash krvikash changed the title Correct exception message when table exists while creating a view Correct exception type when table exists while creating a view Jan 3, 2023
@krvikash krvikash force-pushed the fix-error-message-when-table-exists-while-creating-view branch from 8451595 to 50e0178 Compare January 3, 2023 15:22
@findinpath
Copy link
Copy Markdown
Contributor

nit: ViewAlreadyExistsException exception is misleading when A table exists while creating a view -> ViewAlreadyExistsException exception is misleading when a table exists while creating a view

A -> a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are other uses of ViewAlreadyExistsException which may be probably replaced by TableAlreadyExistsException.

If you replace all of them, then probably ViewAlreadyExistsException may be removed.

cc @electrum

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ViewAlreadyExistsException is required for the case when a view already exists while creating a view.

This PR specially deals with when A table exists while creating a view.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the cases where currently ViewAlreadyExistsException we are doing previously metastore.getTable(..) calls.
I'm thinking that if the metastore calls for a "table", then TableAlreadyExistsException is appropriate.

ViewAlreadyExistsException exception is misleading when a table exists
while creating a view. Changing it to TableAlreadyExistsException.
@krvikash krvikash force-pushed the fix-error-message-when-table-exists-while-creating-view branch from 50e0178 to c6b98ea Compare January 4, 2023 17:15
@alexjo2144
Copy link
Copy Markdown
Member

The TableAlreadyExistsException is probably going to be right most of the time, but it's still potentially wrong. The entity might be a Materialized View or a Hive View for example. Maybe we want a more generic error type that doesn't specify what the thing is.

doCreateView(temporaryCreateView, false);
fail("create existing should fail");
}
catch (TableAlreadyExistsException e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shall we remove the catch (ViewAlreadyExistsExcept clause below?

Optional<com.amazonaws.services.glue.model.Table> existing = getTable(session, schemaViewName);
if (existing.isPresent()) {
if (!replace || !isPrestoView(firstNonNull(existing.get().getParameters(), ImmutableMap.of()))) {
// TODO: ViewAlreadyExists is misleading if the name is used by a table https://github.com/trinodb/trino/issues/10037
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this PR supposed to close that issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think Issue #10037 should have been closed by #10186.

the issue is currently open

@findepi
Copy link
Copy Markdown
Member

findepi commented Feb 7, 2023

@krvikash please rebase, there is a conflict

@github-actions
Copy link
Copy Markdown

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 Feb 28, 2023
@bitsondatadev
Copy link
Copy Markdown
Member

@krvikash, is this PR still active? Could you rebase this please?

@github-actions github-actions bot removed the stale label Mar 3, 2023
@ebyhr ebyhr removed their request for review May 16, 2023 05:11
@github-actions
Copy link
Copy Markdown

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 Jan 17, 2024
@mosabua
Copy link
Copy Markdown
Member

mosabua commented Jan 17, 2024

Closing this one out due to inactivity, but please reopen if you would like to pick this back up.

@mosabua mosabua closed this Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed no-release-notes This pull request does not require release notes entry stale

Development

Successfully merging this pull request may close these issues.

6 participants