Skip to content
Merged
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 @@ -176,6 +176,13 @@ private List<String> validZOrderColNames(
Set<Integer> identityPartitionFieldIds = table.spec().identitySourceIds();
boolean caseSensitive = SparkUtil.caseSensitive(spark);

Preconditions.checkArgument(
caseSensitive
? schema.findField(Z_COLUMN) == null
: schema.caseInsensitiveFindField(Z_COLUMN) == null,
"Cannot zorder because the table has a column named '%s', which conflicts with Iceberg's internal Z-order column name",
Z_COLUMN);

List<String> validZOrderColNames = Lists.newArrayList();

for (String colName : inputZOrderColNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,26 @@ public void testCommitStateUnknownException() {
shouldHaveSnapshots(table, 2); // Commit actually Succeeded
}

@TestTemplate
public void testZOrderWithZColumnCollision() {
Schema schema =
new Schema(
optional(1, "c1", Types.IntegerType.get()),
optional(2, "c2", Types.StringType.get()),
optional(3, "ICEZVALUE", Types.StringType.get()));

Table table =
TABLES.create(
schema,
PartitionSpec.unpartitioned(),
ImmutableMap.of(TableProperties.FORMAT_VERSION, String.valueOf(formatVersion)),
tableLocation);

assertThatThrownBy(() -> basicRewrite(table).zOrder("c1", "c2").execute())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Cannot zorder because the table has a column named 'ICEZVALUE'");
}

@TestTemplate
public void testZOrderSort() {
int originalFiles = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ private List<String> validZOrderColNames(
Set<Integer> identityPartitionFieldIds = table.spec().identitySourceIds();
boolean caseSensitive = SparkUtil.caseSensitive(spark);

Preconditions.checkArgument(
caseSensitive
? schema.findField(Z_COLUMN) == null
: schema.caseInsensitiveFindField(Z_COLUMN) == null,
"Cannot zorder because the table has a column named '%s', which conflicts with Iceberg's internal Z-order column name",
Z_COLUMN);

List<String> validZOrderColNames = Lists.newArrayList();

for (String colName : inputZOrderColNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,26 @@ public void testCommitStateUnknownException() {
shouldHaveSnapshots(table, 2); // Commit actually Succeeded
}

@TestTemplate
public void testZOrderWithZColumnCollision() {
Schema schema =
new Schema(
optional(1, "c1", Types.IntegerType.get()),
optional(2, "c2", Types.StringType.get()),
optional(3, "ICEZVALUE", Types.StringType.get()));

Table table =
TABLES.create(
schema,
PartitionSpec.unpartitioned(),
ImmutableMap.of(TableProperties.FORMAT_VERSION, String.valueOf(formatVersion)),
tableLocation);

assertThatThrownBy(() -> basicRewrite(table).zOrder("c1", "c2").execute())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Cannot zorder because the table has a column named 'ICEZVALUE'");
}

@TestTemplate
public void testZOrderSort() {
int originalFiles = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ private List<String> validZOrderColNames(
Set<Integer> identityPartitionFieldIds = table.spec().identitySourceIds();
boolean caseSensitive = SparkUtil.caseSensitive(spark);

Preconditions.checkArgument(
caseSensitive
? schema.findField(Z_COLUMN) == null
: schema.caseInsensitiveFindField(Z_COLUMN) == null,
"Cannot zorder because the table has a column named '%s', which conflicts with Iceberg's internal Z-order column name",
Z_COLUMN);

List<String> validZOrderColNames = Lists.newArrayList();

for (String colName : inputZOrderColNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,26 @@ public void testCommitStateUnknownException() {
shouldHaveSnapshots(table, 2); // Commit actually Succeeded
}

@TestTemplate
public void testZOrderWithZColumnCollision() {
Schema schema =
new Schema(
optional(1, "c1", Types.IntegerType.get()),
optional(2, "c2", Types.StringType.get()),
optional(3, "ICEZVALUE", Types.StringType.get()));

Table table =
TABLES.create(
schema,
PartitionSpec.unpartitioned(),
ImmutableMap.of(TableProperties.FORMAT_VERSION, String.valueOf(formatVersion)),
tableLocation);

assertThatThrownBy(() -> basicRewrite(table).zOrder("c1", "c2").execute())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Cannot zorder because the table has a column named 'ICEZVALUE'");
}

@TestTemplate
public void testZOrderSort() {
int originalFiles = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ private List<String> validZOrderColNames(
Set<Integer> identityPartitionFieldIds = table.spec().identitySourceIds();
boolean caseSensitive = SparkUtil.caseSensitive(spark);

Preconditions.checkArgument(
caseSensitive
? schema.findField(Z_COLUMN) == null
: schema.caseInsensitiveFindField(Z_COLUMN) == null,
"Cannot zorder because the table has a column named '%s', which conflicts with Iceberg's internal Z-order column name",
Z_COLUMN);

List<String> validZOrderColNames = Lists.newArrayList();

for (String colName : inputZOrderColNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,26 @@ public void testCommitStateUnknownException() {
shouldHaveSnapshots(table, 2); // Commit actually Succeeded
}

@TestTemplate
public void testZOrderWithZColumnCollision() {
Schema schema =
new Schema(
optional(1, "c1", Types.IntegerType.get()),
optional(2, "c2", Types.StringType.get()),
optional(3, "ICEZVALUE", Types.StringType.get()));

Table table =
TABLES.create(
schema,
PartitionSpec.unpartitioned(),
ImmutableMap.of(TableProperties.FORMAT_VERSION, String.valueOf(formatVersion)),
tableLocation);

assertThatThrownBy(() -> basicRewrite(table).zOrder("c1", "c2").execute())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Cannot zorder because the table has a column named 'ICEZVALUE'");
}

@TestTemplate
public void testZOrderSort() {
int originalFiles = 20;
Expand Down
Loading