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 @@ -317,4 +317,39 @@ class AuronQuerySuite
checkAnswer(sql(q), Seq(expected))
}
}

test("initcap basic") {
Seq(
("select initcap('spark sql')", Row("Spark Sql")),
("select initcap('SPARK')", Row("Spark")),
("select initcap('sPaRk')", Row("Spark")),
("select initcap('')", Row("")),
("select initcap(null)", Row(null))).foreach { case (q, expected) =>
checkAnswer(sql(q), Seq(expected))
}
}

test("initcap: word boundaries and punctuation") {
Seq(
("select initcap('hello world')", Row("Hello World")),
("select initcap('hello_world')", Row("Hello_world")),
("select initcap('über-alles')", Row("Über-alles")),
("select initcap('foo.bar/baz')", Row("Foo.bar/baz")),
("select initcap('v2Ray is COOL')", Row("V2ray Is Cool")),
("select initcap('rock''n''roll')", Row("Rocknroll")),
("select initcap('hi\\tthere')", Row("Hi\tthere")),
("select initcap('hi\\nthere')", Row("Hi\nthere"))).foreach { case (q, expected) =>
checkAnswer(sql(q), Seq(expected))
}
}

test("initcap: mixed cases and edge cases") {
Seq(
("select initcap('a1b2 c3D4')", Row("A1b2 C3d4")),
("select initcap('---abc---')", Row("---abc---")),
("select initcap(' multiple spaces ')", Row(" Multiple Spaces "))).foreach {
case (q, expected) =>
checkAnswer(sql(q), Seq(expected))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,8 @@ object NativeConverters extends Logging {
buildScalarFunction(pb.ScalarFunction.MD5, Seq(unpackBinaryTypeCast(_1)), StringType)
case Reverse(_1) =>
buildScalarFunction(pb.ScalarFunction.Reverse, Seq(unpackBinaryTypeCast(_1)), StringType)
case InitCap(_1) =>
buildScalarFunction(pb.ScalarFunction.InitCap, Seq(unpackBinaryTypeCast(_1)), StringType)
case Sha2(_1, Literal(224, _)) =>
buildExtScalarFunction("Sha224", Seq(unpackBinaryTypeCast(_1)), StringType)
case Sha2(_1, Literal(0, _)) =>
Expand Down
Loading