Skip to content

Commit

Permalink
Fix failure when inserting into Kudu table having row uuid column
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Jun 21, 2022
1 parent dec1ed6 commit 1b60552
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,27 @@ public class KuduInsertTableHandle
{
private final SchemaTableName schemaTableName;
private final List<Type> columnTypes;
private final boolean generateUUID;
private transient KuduTable table;

@JsonCreator
public KuduInsertTableHandle(
@JsonProperty("schemaTableName") SchemaTableName schemaTableName,
@JsonProperty("columnTypes") List<Type> columnTypes)
@JsonProperty("columnTypes") List<Type> columnTypes,
@JsonProperty("generateUUID") boolean generateUUID)
{
this(schemaTableName, columnTypes, null);
this(schemaTableName, columnTypes, generateUUID, null);
}

public KuduInsertTableHandle(
SchemaTableName schemaTableName,
List<Type> columnTypes,
boolean generateUUID,
KuduTable table)
{
this.schemaTableName = requireNonNull(schemaTableName, "schemaTableName is null");
this.columnTypes = ImmutableList.copyOf(requireNonNull(columnTypes, "columnTypes is null"));
this.generateUUID = generateUUID;
this.table = table;
}

Expand All @@ -70,9 +74,10 @@ public List<Type> getOriginalColumnTypes()
}

@Override
@JsonProperty
public boolean isGenerateUUID()
{
return false;
return generateUUID;
}

public KuduTable getTable(KuduClientSession session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ public ConnectorInsertTableHandle beginInsert(ConnectorSession session, Connecto
return new KuduInsertTableHandle(
tableHandle.getSchemaTableName(),
columnTypes,
columns.stream()
.anyMatch(column -> column.getName().equals(ROW_ID)),
table);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,17 @@ public void testInsert()
throw new SkipException("TODO");
}

@Test
public void testInsertIntoTableHavingRowUuid()
{
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_insert_", " AS SELECT * FROM region WITH NO DATA")) {
assertUpdate("INSERT INTO " + table.getName() + " SELECT * FROM region", 5);

assertThat(query("SELECT * FROM " + table.getName()))
.matches("SELECT * FROM region");
}
}

@Test
@Override
public void testInsertUnicode()
Expand Down

0 comments on commit 1b60552

Please sign in to comment.