Skip to content

Conversation

@ebyhr
Copy link
Member

@ebyhr ebyhr commented Dec 7, 2021

No description provided.

@cla-bot cla-bot bot added the cla-signed label Dec 7, 2021
Copy link
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.

I think the intention of the test originally was to verify that if a CREATE TABLE issued from Trino had NOT NULL columns then writiing NULL to those columns would fail (by the engine, not the remote database). So the error message should be from the engine like NULL value not allowed for NOT NULL column: <column_name>. See https://github.com/trinodb/trino/pull/4144/files#diff-17c56008a5b3b294ad78fca3ce68faef643ff3eea9c5a512fca8e2c753d1d09bR266-R268

This change instead looks to be testing the behaviour of remote database regarding NULL values being inserted into NOT NULL columns.

EDIT: After reading the base test impl I can see the difference.

Copy link
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.

Looks good to me.

@ebyhr ebyhr force-pushed the ebi/test-insert-not-null branch 2 times, most recently from ae23e56 to 70c0cec Compare December 7, 2021 07:16
@ebyhr ebyhr force-pushed the ebi/test-insert-not-null branch from 70c0cec to 76eb5b4 Compare December 7, 2021 08:59
@ebyhr ebyhr force-pushed the ebi/test-insert-not-null branch from 76eb5b4 to 3c3af03 Compare December 7, 2021 12:29
@ebyhr ebyhr assigned ebyhr and unassigned ebyhr Dec 7, 2021
@ebyhr ebyhr merged commit 5b785cf into master Dec 7, 2021
@ebyhr ebyhr deleted the ebi/test-insert-not-null branch December 7, 2021 15:35
@github-actions github-actions bot added this to the 366 milestone Dec 7, 2021
SUPPORTS_RENAME_MATERIALIZED_VIEW_ACROSS_SCHEMAS(SUPPORTS_RENAME_MATERIALIZED_VIEW),

SUPPORTS_INSERT,
SUPPORTS_INSERT_NOT_NULL_COLUMN(SUPPORTS_INSERT),
Copy link
Member

Choose a reason for hiding this comment

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

call it SUPPORTS_NOT_NULL_CONSTRAINT

Copy link
Member

@hashhar hashhar Dec 8, 2021

Choose a reason for hiding this comment

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

That's misleading (and the cause for my earlier confusion). The constraint is applied by the engine and all connectors "support" it. This is about more about whether the connector allows missing columns on insert (so that remote database replaces missing columns with default values).

Maybe SUPPORTS_DEFAULT_VALUES_FOR_MISSING_COLUMNS or SUPPORTS_MISSING_COLUMNS_ON_INSERT?

Copy link
Member

@findepi findepi Dec 8, 2021

Choose a reason for hiding this comment

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

The constraint is applied by the engine and all connectors "support" it

it is applied by the engine, if the connector declares the column as NOT NULL.
It may fail to update io.trino.spi.connector.ColumnMetadata#nullable.

Also, in case io.trino.spi.connector.ConnectorMetadata#supportsMissingColumnsOnInsert, the engine does not enforce NOT NULLs, right?

This is about more about whether the connector allows missing columns on insert

This should be invisible from end user perspective, so we shouldn't ned a TestingConnectorBehavior for this.

so that remote database replaces missing columns with default values).

isn't this related to (or covered by) io.trino.testing.AbstractTestDistributedQueries#testInsertForDefaultColumn?

Copy link
Member

Choose a reason for hiding this comment

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

@hashhar wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I re-read both the tests (testInsertForDefaultColumn and the one we moved here). It's slightly confusing that missing columns on insert is tested as part of testInsertIntoNotNullColumn. Maybe we should remove that (since it's covered by testInsertForDefaultColumn already).

Agreed on all other points.

cc: @ebyhr

Copy link
Member

Choose a reason for hiding this comment

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

It's slightly confusing that missing columns on insert is tested as part of testInsertIntoNotNullColumn.

i may agree.
It's important to test INSERT with NOT NULL with explicit values and defaults, but whether this is single test method, or two test methods is secondary.

Maybe we should remove that (since it's covered by testInsertForDefaultColumn already).

or, maybe we let testInsertForDefaultColumn test aspects of INSERTS other than NOT NULL constraints?

Copy link
Member

Choose a reason for hiding this comment

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

I agree. I'll send a PR that applies your comments.

Copy link
Member

Choose a reason for hiding this comment

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

Seems @ebyhr resolved this already in #10278

@Test
public void testInsertIntoNotNullColumn()
{
skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE) && hasBehavior(SUPPORTS_INSERT_NOT_NULL_COLUMN));
Copy link
Member

Choose a reason for hiding this comment

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

when !hasBehavior(...), verify that CREATE TABLE t(a .. NOT NULL) is rejected as unsupported (is it?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I will send a new PR.

}

@Test
@Override
Copy link
Member

Choose a reason for hiding this comment

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

Why? document

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.

4 participants