Skip to content

Commit

Permalink
Make sure cosine_similarity works with the new function registration …
Browse files Browse the repository at this point in the history
…interface
  • Loading branch information
MrPowers committed May 10, 2021
1 parent 68460b8 commit 67ccbbb
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/test/scala/org/apache/itachi/ItachiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ItachiTest extends SparkSessionHelper {
override def beforeAll(): Unit = {
super.beforeAll()
org.apache.itachi.registerPostgresFunctions
org.apache.itachi.registerTeradataFunctions
}

def checkAnswer(df: DataFrame, expect: Seq[Row]): Unit = {
Expand All @@ -48,14 +49,9 @@ class ItachiTest extends SparkSessionHelper {
checkAnswer(sql("SELECT REGR_COUNT(1, null)"), Seq(Row(0)))
}

// test("index") {
// org.apache.itachi.registerTeradataFunctions
// val res1 = spark.sql("select index('foobarbar', 'bar')")
// .head().getInt(0)
// assert(res1 === 4)
// val res2 = spark.sql("select index(b, a) from values('bar', 'foobarbar') t(a, b)")
// .head().getInt(0)
// assert(res2 === 4)
// }
test("cosine_similarity") {
val frame = spark.sql("SELECT cosine_similarity(MAP('a', 1.0), MAP('a', 2.0))")
checkAnswer(frame, Seq(Row(1.0)))
}

}

0 comments on commit 67ccbbb

Please sign in to comment.