Skip to content

Commit

Permalink
changed CollationIdentifier constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ilicmarkodb committed Sep 16, 2024
1 parent 4c7d72f commit d95ebc0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public CollationIdentifier(String provider, String collationName) {
this.version = Optional.empty();
}

public CollationIdentifier(String provider, String collationName, String version) {
public CollationIdentifier(String provider, String collationName, Optional<String> version) {
Objects.requireNonNull(provider, "Collation provider cannot be null.");
Objects.requireNonNull(collationName, "Collation name cannot be null.");
Objects.requireNonNull(version, "Provider version cannot be null.");

this.provider = provider.toUpperCase();
this.name = collationName.toUpperCase();
this.version = Optional.of(version);
this.version = version.map(String::toUpperCase);
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public static CollationIdentifier fromString(String identifier) {
return new CollationIdentifier(parts[0], parts[1]);
} else {
String[] parts = identifier.split("\\.", 3);
return new CollationIdentifier(parts[0], parts[1], parts[2]);
return new CollationIdentifier(parts[0], parts[1], Optional.of(parts[2]));
}
}

Expand Down Expand Up @@ -132,3 +132,4 @@ public String toString() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private List<Tuple2<String, String>> getNestedCollatedFields(DataType parent, St
StringType stringType = (StringType) parent;
if (!stringType
.getCollationIdentifier()
.equals(CollationIdentifier.DEFAULT_COLLATION_IDENTIFIER)) {
.equals(CollationIdentifier.fromString("SPARK.UTF8_BINARY"))) {
nestedCollatedFields.add(
new Tuple2<>(
path, ((StringType) parent).getCollationIdentifier().toStringWithoutVersion()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package io.delta.kernel.types

import org.scalatest.funsuite.AnyFunSuite

import java.util.Optional

class CollationIdentifierSuite extends AnyFunSuite {
val PROVIDER_SPARK = "SPARK"
val PROVIDER_ICU = "ICU"
Expand All @@ -35,7 +37,7 @@ class CollationIdentifierSuite extends AnyFunSuite {
),
(
s"$PROVIDER_ICU.sr_Cyrl_SRB.75.1",
new CollationIdentifier(PROVIDER_ICU, "sr_Cyrl_SRB", "75.1")
new CollationIdentifier(PROVIDER_ICU, "sr_Cyrl_SRB", Optional.of("75.1"))
)
).foreach {
case(stringIdentifier, collationIdentifier) =>
Expand Down Expand Up @@ -67,7 +69,7 @@ class CollationIdentifierSuite extends AnyFunSuite {
s"$PROVIDER_ICU.SR_CYRL_SRB"
),
(
new CollationIdentifier(PROVIDER_ICU, "sr_Cyrl_SRB", "75.1"),
new CollationIdentifier(PROVIDER_ICU, "sr_Cyrl_SRB", Optional.of("75.1")),
s"$PROVIDER_ICU.SR_CYRL_SRB"
)
).foreach {
Expand All @@ -87,7 +89,7 @@ class CollationIdentifierSuite extends AnyFunSuite {
s"$PROVIDER_ICU.SR_CYRL_SRB"
),
(
new CollationIdentifier(PROVIDER_ICU, "sr_Cyrl_SRB", "75.1"),
new CollationIdentifier(PROVIDER_ICU, "sr_Cyrl_SRB", Optional.of("75.1")),
s"$PROVIDER_ICU.SR_CYRL_SRB.75.1"
)
).foreach {
Expand All @@ -96,3 +98,4 @@ class CollationIdentifierSuite extends AnyFunSuite {
}
}
}

0 comments on commit d95ebc0

Please sign in to comment.