-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Support MERGE for MySQL connector #24428
base: master
Are you sure you want to change the base?
Conversation
plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java
Show resolved
Hide resolved
b4e8e08
to
c0b86ce
Compare
Is there a test verifying error message when executing MERGE statement on table without primary keys? |
a4d84a0
to
3deed31
Compare
537b087
to
1146ad7
Compare
This pull request has gone a while without any activity. Tagging for triage help: @mosabua |
d20d159
to
5b93e35
Compare
Dont forget the docs update .. should be an easy one line include now .. |
5b93e35
to
d25cda3
Compare
Thank you @chenjian2664 |
protected void testUpdateWithSubquery() | ||
{ | ||
assertThatThrownBy(super::testUpdateWithSubquery).hasMessageContaining("Non-transactional MERGE is disabled"); | ||
abort("skipped"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this test have abort
and other two tests don't have the call?
case SUPPORTS_ROW_LEVEL_UPDATE: | ||
case SUPPORTS_MERGE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order by alphabetically.
@Override | ||
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) | ||
{ | ||
switch (connectorBehavior) { | ||
case SUPPORTS_RENAME_SCHEMA: | ||
return false; | ||
|
||
case SUPPORTS_ROW_LEVEL_UPDATE: | ||
case SUPPORTS_MERGE: | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move true
cases above false
case.
protected TestTable createTestTableForWrites(String tablePrefix) | ||
{ | ||
TestTable table = super.createTestTableForWrites(tablePrefix); | ||
String tableName = table.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline tableName
.
protected TestTable createTestTableForWrites(String namePrefix, String tableDefinition, String primaryKey) | ||
{ | ||
TestTable testTable = super.createTestTableForWrites(namePrefix, tableDefinition, primaryKey); | ||
String tableName = testTable.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline tableName
.
protected TestTable createTestTableForWrites(String namePrefix, String tableDefinition, List<String> rowsToInsert, String primaryKey) | ||
{ | ||
TestTable testTable = super.createTestTableForWrites(namePrefix, tableDefinition, rowsToInsert, primaryKey); | ||
String tableName = testTable.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline tableName
.
} | ||
|
||
@Test | ||
public void testMergeTargetWithNoPrimaryKeys() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testMergeTargetWithNoPrimaryKeys() | |
public void testMergeTargetWithoutPrimaryKeys() |
assertQueryFails(format("DELETE FROM %s WHERE a IS NOT NULL AND abs(a + b) > 10", tableName), "The connector can not perform merge on the target table without primary keys"); | ||
assertQueryFails(format("UPDATE %s SET a = a+b WHERE a IS NOT NULL AND (a + b) > 10", tableName), "The connector can not perform merge on the target table without primary keys"); | ||
assertQueryFails(format("MERGE INTO %s t USING (VALUES (3, 3)) AS s(x, y) " + | ||
" ON t.a = s.x " + | ||
" WHEN MATCHED THEN UPDATE SET b = y " + | ||
" WHEN NOT MATCHED THEN INSERT (a, b) VALUES (s.x, s.y) ", tableName), "The connector can not perform merge on the target table without primary keys"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception comes from DefaultJdbcMetadata, not MySQL connector. Can we move this test to BaseJdbcConnectorTest
?
|
||
Set<String> primaryKeyNames = new HashSet<>(); | ||
while (primaryKeys.next()) { | ||
String columnName = primaryKeys.getString("COLUMN_NAME"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline columnName
.
continue; | ||
} | ||
JdbcTypeHandle handle = columnHandle.getJdbcTypeHandle(); | ||
CaseSensitivity caseSensitivity = handle.caseSensitivity().orElse(CASE_INSENSITIVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to set CASE_INSENSITIVE by default?
Description
The tests that are updated in the
BaseJdbcConnectorTest
because current the implementation of MERGE for Mysql connector requires the table has primary keys, thus modified the table creation logic to usecreateTestTableForWrites
, allowing the MySQL connector test class to override it and add primary keys as needed.Release notes