Skip to content
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

Qualification tool: Filter empty strings from Read Schema #3405

Merged
merged 2 commits into from
Sep 8, 2021
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 @@ -335,7 +335,7 @@ object QualAppInfo extends Logging {
val individualSchema: ArrayBuffer[String] = new ArrayBuffer()
var angleBracketsCount = 0
var parenthesesCount = 0
val distinctSchema = schema.distinct.mkString(",")
val distinctSchema = schema.distinct.filter(_.nonEmpty).mkString(",")

// Get the nested types i.e everything between < >
for (char <- distinctSchema) {
Expand All @@ -351,8 +351,7 @@ object QualAppInfo extends Logging {
if (angleBracketsCount == 0 && parenthesesCount == 0 && char.equals(',')) {
individualSchema += tempStringBuilder.toString
tempStringBuilder.setLength(0)
}
else {
} else {
tempStringBuilder.append(char);
}
}
tgravescs marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -368,13 +367,30 @@ object QualAppInfo extends Logging {
// Check if it has types
val incompleteTypes = incompleteSchema.map { x =>
if (x.contains("...") && x.contains(":")) {
x.split(":", 2)(1).split("\\.\\.\\.")(0)
val schemaTypes = x.split(":", 2)
if (schemaTypes.size == 2) {
val partialSchema = schemaTypes(1).split("\\.\\.\\.")
if (partialSchema.size == 1) {
partialSchema(0)
} else {
""
}
} else {
""
}
} else {
""
}
}
// Omit columnName and get only schemas
val completeTypes = completeSchema.map(x => x.split(":", 2)(1))
val completeTypes = completeSchema.map { x =>
val schemaTypes = x.split(":", 2)
if (schemaTypes.size == 2) {
schemaTypes(1)
} else {
""
}
}
val schemaTypes = completeTypes ++ incompleteTypes

// Filter only complex types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class QualificationSuite extends FunSuite with BeforeAndAfterEach with Logging {
test("test different types in ReadSchema") {
val testSchemas: ArrayBuffer[ArrayBuffer[String]] = ArrayBuffer(
ArrayBuffer(""),
ArrayBuffer("firstName:string,lastName:string"),
ArrayBuffer("firstName:string,lastName:string", "", "address:string"),
ArrayBuffer("properties:map<string,string>"),
ArrayBuffer("name:array<string>"),
ArrayBuffer("name:string,booksInterested:array<struct<name:string,price:decimal(8,2)," +
Expand Down