Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3270,14 +3270,14 @@ protected Scope visitUpdate(Update update, Optional<Scope> scope)
.collect(toImmutableMap(ColumnSchema::getName, Function.identity()));

for (UpdateAssignment assignment : update.getAssignments()) {
String columnName = assignment.getName().getValue();
String columnName = assignment.getName().getValue().toLowerCase(ENGLISH);
if (!columns.containsKey(columnName)) {
throw semanticException(COLUMN_NOT_FOUND, assignment.getName(), "The UPDATE SET target column %s doesn't exist", columnName);
}
}

Set<String> assignmentTargets = update.getAssignments().stream()
.map(assignment -> assignment.getName().getValue())
.map(assignment -> assignment.getName().getValue().toLowerCase(ENGLISH))
.collect(toImmutableSet());
accessControl.checkCanUpdateTableColumns(session.toSecurityContext(), tableName, assignmentTargets);

Expand Down Expand Up @@ -3325,7 +3325,7 @@ protected Scope visitUpdate(Update update, Optional<Scope> scope)
List<Type> expressionTypes = expressionTypesBuilder.build();

List<Type> tableTypes = update.getAssignments().stream()
.map(assignment -> requireNonNull(columns.get(assignment.getName().getValue())))
.map(assignment -> requireNonNull(columns.get(assignment.getName().getValue().toLowerCase(ENGLISH))))
.map(ColumnSchema::getType)
.collect(toImmutableList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
import static io.trino.type.IntervalDayTimeType.INTERVAL_DAY_TIME;
import static io.trino.type.IntervalYearMonthType.INTERVAL_YEAR_MONTH;
import static java.lang.String.format;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;

class QueryPlanner
Expand Down Expand Up @@ -600,7 +601,7 @@ public PlanNode plan(Update node)

Expression[] orderedColumnValuesArray = new Expression[updatedColumnHandles.size()];
node.getAssignments().forEach(assignment -> {
String name = assignment.getName().getValue();
String name = assignment.getName().getValue().toLowerCase(ENGLISH);
ColumnHandle handle = nameToHandle.get(name);
int index = updatedColumnHandles.indexOf(handle);
if (index >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ public void testUpdate()
.hasMessage(MODIFYING_NON_TRANSACTIONAL_TABLE_MESSAGE);
}

@Override
public void testUpdateCaseSensitivity()
{
assertThatThrownBy(super::testUpdateCaseSensitivity)
.hasMessage(MODIFYING_NON_TRANSACTIONAL_TABLE_MESSAGE);
}

@Test
@Override
public void testUpdateRowConcurrently()
throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,15 @@ public void testUpdate()
});
}

/**
* This test fails intermittently because Kudu doesn't have strong enough
* semantics to support writing from multiple threads.
*/
@Test(enabled = false)
@Override
public void testUpdateCaseSensitivity() {}

@Test
@Override
public void testUpdateRowConcurrently()
throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4651,6 +4651,17 @@ public void testUpdate()
}
}

@Test
public void testUpdateCaseSensitivity()
{
skipTestUnless(hasBehavior(SUPPORTS_UPDATE));

try (TestTable table = new TestTable(getQueryRunner()::execute, "test_row_update", "AS SELECT * FROM nation")) {
assertUpdate("UPDATE " + table.getName() + " SET NATIONKEY = 100 WHERE REGIONKEY = 2", 5);
assertQuery("SELECT count(*) FROM " + table.getName() + " WHERE nationkey = 100", "VALUES 5");
}
}

// Repeat test with invocationCount for better test coverage, since the tested aspect is inherently non-deterministic.
@Test(timeOut = 60_000, invocationCount = 4)
public void testUpdateRowConcurrently()
Expand Down