Skip to content
Next Next commit
fix show functions
  • Loading branch information
AngersZhuuuu committed Oct 8, 2019
commit 911007a45f39fd3570613d73c94381eed79d3ac0
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,6 @@ case class ShowFunctionsCommand(
case (f, "USER") if showUserFunctions => f.unquotedString
case (f, "SYSTEM") if showSystemFunctions => f.unquotedString
}
functionNames.sorted.map(Row(_))
(functionNames ++ Seq("!=", "<>", "between", "case")).sorted.map(Row(_))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession {

createFunction(functions)

checkAnswer(sql("SHOW functions"), getFunctions("*"))
checkAnswer(sql("SHOW functions"), (getFunctions("*") ++
Seq(Row("!="), Row("<>"), Row("between"), Row("case"))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shall we put this code in getFunctions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shall we put this code in getFunctions?

Good ideal, I will try this.

assert(sql("SHOW functions").collect().size > 200)

Seq("^c*", "*e$", "log*", "*date*").foreach { pattern =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2065,12 +2065,12 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
test("show functions") {
withUserDefinedFunction("add_one" -> true) {
val numFunctions = FunctionRegistry.functionSet.size.toLong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we update it with val numFunctions = ... + 4?

assert(sql("show functions").count() === numFunctions)
assert(sql("show functions").count() === numFunctions + 4L)
assert(sql("show system functions").count() === numFunctions)
assert(sql("show all functions").count() === numFunctions)
assert(sql("show user functions").count() === 0L)
spark.udf.register("add_one", (x: Long) => x + 1)
assert(sql("show functions").count() === numFunctions + 1L)
assert(sql("show functions").count() === numFunctions + 5L)
assert(sql("show system functions").count() === numFunctions)
assert(sql("show all functions").count() === numFunctions + 1L)
assert(sql("show user functions").count() === 1L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ class HiveUDFSuite extends QueryTest with TestHiveSingleton with SQLTestUtils {
checkAnswer(
sql("SELECT testUDFToListInt(s) FROM inputTable"),
Seq(Row(Seq(1, 2, 3))))
assert(sql("show functions").count() == numFunc + 1)
assert(spark.catalog.listFunctions().count() == numFunc + 1)
assert(sql("show functions").count() == numFunc + 5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Could you help to trigger retest ?

assert(spark.catalog.listFunctions().count() == numFunc + 5)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
allBuiltinFunctions.foreach { f =>
assert(allFunctions.contains(f))
}

Seq("!=", "<>", "between", "case").foreach { f =>
assert(allFunctions.contains(f))
}

withTempDatabase { db =>
def createFunction(names: Seq[String]): Unit = {
names.foreach { name =>
Expand Down