Skip to content

Commit

Permalink
remove non relevant tests from this PR
Browse files Browse the repository at this point in the history
Signed-off-by: YANGDB <[email protected]>
  • Loading branch information
YANG-DB committed Nov 8, 2024
1 parent 1f2ae52 commit 7c63446
Showing 1 changed file with 1 addition and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,49 +35,7 @@ class FlintSparkPPLGrokITSuite
job.awaitTermination()
}
}

test("test grok hostname | head ") {
val frame = sql(s"""
| source = $testTable| grok email '.+@%{HOSTNAME:host}'| sort host | head 5
| """.stripMargin)

// Retrieve the results
val results: Array[Row] = frame.collect()
// Define the expected results
val expectedResults: Array[Row] = Array(
Row("[email protected]", "anotherdomain.com"),
Row("[email protected]", "demo.net"),
Row("[email protected]", "demonstration.com"),
Row("[email protected]", "domain.net"),
Row("[email protected]", "example.com"))

// Compare the results
implicit val rowOrdering: Ordering[Row] = Ordering.by[Row, String](_.getAs[String](0))
assert(results.sorted.sameElements(expectedResults.sorted))

// Retrieve the logical plan
val logicalPlan: LogicalPlan = frame.queryExecution.logical

val emailAttribute = UnresolvedAttribute("email")
val hostExpression = Alias(
RegExpExtract(
emailAttribute,
Literal(
".+@(?<name0>\\b(?:[0-9A-Za-z][0-9A-Za-z-]{0,62})(?:\\.(?:[0-9A-Za-z][0-9A-Za-z-]{0,62}))*(\\.?|\\b))"),
Literal("1")),
"host")()
val expectedPlan = Project(
Seq(UnresolvedStar(None)),
GlobalLimit(
Literal(1000),
LocalLimit(
Literal(1000),
Project(
Seq(emailAttribute, hostExpression, UnresolvedStar(None)),
UnresolvedRelation(Seq("accounts"))))))
assert(compareByString(expectedPlan) === compareByString(logicalPlan))
}


test("test grok email expressions parsing") {
val frame = sql(s"""
| source = $testTable| grok email '.+@%{HOSTNAME:host}' | fields email, host
Expand Down

0 comments on commit 7c63446

Please sign in to comment.