Skip to content

Deny adding column with comment if the connector does not support this feature#11493

Merged
ebyhr merged 4 commits intotrinodb:masterfrom
findinpath:iceberg-test-add-column-with-comment-rename
Apr 4, 2022
Merged

Deny adding column with comment if the connector does not support this feature#11493
ebyhr merged 4 commits intotrinodb:masterfrom
findinpath:iceberg-test-add-column-with-comment-rename

Conversation

@findinpath
Copy link
Copy Markdown
Contributor

@findinpath findinpath commented Mar 15, 2022

Description

Deny adding column with comment if the connector does not support this feature

Is this change a fix, improvement, new feature, refactoring, or other?

Refactoring

Is this a change to the core query engine, a connector, client library, or the SPI interfaces? (be specific)

All the connectors

How would you describe this change to a non-technical end user or system administrator?

Deny adding column with comment if the connector does not support this feature

Related issues, pull requests, and links

Fixes #11486

Documentation

(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.

Release notes

() No release notes entries required.
(x) Release notes entries required with the following suggested text:

# General
* Deny adding column with comment if the connector does not support this feature. ({issue}`11486`)

# Kudu
* Add support for adding columns with comment. ({issue}`11486`)

@cla-bot cla-bot bot added the cla-signed label Mar 15, 2022
@findinpath findinpath requested review from ebyhr and hashhar March 15, 2022 11:25
@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch from 49bd2ba to 3df752d Compare March 15, 2022 11:26
findepi
findepi previously approved these changes Mar 15, 2022
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.

BCT should provide sufficient coverage for adding column with comment. The test doesn't need to be Iceberg-specific.

cc @hashhar @ebyhr

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.

Yes, I filed #11486 yesterday.

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.

I moved the test to BaseConnectorTest.
If the column comment functionality is not available on ADD COLUMN we'll probably need a new entry in TestingConnectorBehavior enum

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.

Yes, I filed #11486 yesterday.

thanks!

please make sure this Iceberg-specific test method gets removed as part of 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.

I've largely shrinked the test to concentrate only on adding a column with comment.
However, there is a series of connectors (e.g.: Postgres, MsSQL) which do support adding columns, but ignore the comment provided.

I'll add a new testing behaviour SUPPORTS_ADD_COLUMN_WITH_COMMENT .

@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch from 3df752d to 383a386 Compare March 16, 2022 05:59
@findepi findepi changed the title Rename method to better suite the purpose of the test Move test for adding column with comment to BaseConnectorTest Mar 16, 2022
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.

it would be weird for a connector to support ADD COLUMN without CREATE TABLE.
I think we can drop this line.

in the worst case, a connector that has exactly such weird behavior will have to override this method, or we bring the condition back (which will perhaps never happen)

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.

yeah skipping would just hide such "broken" (IMO) connectors.

Copy link
Copy Markdown
Contributor Author

@findinpath findinpath Mar 18, 2022

Choose a reason for hiding this comment

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

Elasticsearch, Redis seems not to support creating tables, but can add columns

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.

why do you think Elasticsearch, Redis support adding columns?

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.

Sorry. My mistake. I misread the test results.

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 we can drop this line.

let's drop the line

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.

Dropped the line and also adjusted Redis & Elasticsearch tests to provide appropriate values for the SUPPORTS_ADD_COLUMN behavior. Thank you (yet again) @findepi for stressing on this aspect.

@ebyhr
Copy link
Copy Markdown
Member

ebyhr commented Mar 16, 2022

Fixes #11162
Fixes #11486

The added test verifies table comments only when the connector supports ADD COLUMN statement. I think we shouldn't close #11162 unless we fix BaseConnectorTest.testCommentColumn() or add another test in this PR.

@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch 3 times, most recently from 08ccda6 to 7638c46 Compare March 16, 2022 15:29
Copy link
Copy Markdown
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

LGTM from me

@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch from 7638c46 to 1492897 Compare March 18, 2022 12:28
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.

This should be handled by declaring that it doesn't have SUPPORTS_ADD_COLUMN_WITH_COMMENT behavior, and checked that the connector indeed rejects column with a comment.

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.

Actually the clickhouse connector test supports adding columns only for MergeTree engine tables:

// Only MergeTree engine table can add column
assertUpdate("CREATE TABLE " + tableName + " (id int NOT NULL, x VARCHAR) WITH (engine = 'MergeTree', order_by = ARRAY['id'])");

However, the column comment is ignored at the moment. This is the reason why the implementation of the test for the Clickhouse connector simply skips testing the functionality.

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.

else (when ! hasBehavior(SUPPORTS_ADD_COLUMN_WITH_COMMENT)) the ALTER TABLE should have failed

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.

I don't fully understand what you mean.

If the connector does support adding columns without comment it will simply ignore the comment provided, but the ADD COLUMN statement will nevertheless succeed.

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.

If the connector does support adding columns without comment it will simply ignore the comment provided

This is a bug, see #11348 (talks about table comments, but same story)

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.

I have updated the PR to reflect this new aspect.
In case that the connector does not support adding a column with comment, it will fail to execute the ADD COLUMN task when the comment is present.

@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch 3 times, most recently from 14f164b to 563b956 Compare March 22, 2022 08:02
@findinpath findinpath changed the title Move test for adding column with comment to BaseConnectorTest Deny adding column with comment if the connector does not support this feature Mar 22, 2022
@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch 2 times, most recently from 0c5a071 to 7e33573 Compare March 22, 2022 10:21
@findepi
Copy link
Copy Markdown
Member

findepi commented Mar 22, 2022

fyi CI red

@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch 2 times, most recently from 076c28b to 7a989ea Compare March 23, 2022 11:19
@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch from 7a989ea to 9e74970 Compare March 24, 2022 15:38
@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch from 6b57929 to 357338b Compare March 25, 2022 05:03
@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch 2 times, most recently from 5c6b410 to 94f7172 Compare March 26, 2022 20:37
@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch from 94f7172 to 2da33a5 Compare March 27, 2022 08:23
@findinpath findinpath requested review from findepi and hashhar March 27, 2022 10:11
@findepi findepi removed their request for review April 1, 2022 08:02
@findepi
Copy link
Copy Markdown
Member

findepi commented Apr 1, 2022

@hashhar @ebyhr @phd3 PTAL

Copy link
Copy Markdown
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

Please fix a test failure in SignleStore connector.

…s feature

Instead of silently ignoring the column comment if the connector
does not support adding column comments, throw explicitly
an exception to expose the fact that this feature is not supported.
@findinpath findinpath force-pushed the iceberg-test-add-column-with-comment-rename branch from be3baab to 96de89d Compare April 4, 2022 12:37
@ebyhr ebyhr merged commit ec3aa36 into trinodb:master Apr 4, 2022
@github-actions github-actions bot added this to the 376 milestone Apr 4, 2022
@ebyhr ebyhr mentioned this pull request Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Add test for ALTER TABLE ADD COLUMN with comment to BaseConnectorTest

4 participants