Skip to content
Prev Previous commit
Next Next commit
fix the HiveSQLViewSuite failure
  • Loading branch information
kevinyu98 committed Jul 10, 2018
commit e030bd014057ad520390936f63542d9a212a63ac
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ private[sql] class HiveSessionCatalog(
super.functionExists(name) || hiveFunctions.contains(name.funcName)
}

override def externalFunctionExists(name: FunctionIdentifier): Boolean = functionExists(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

According to your logic, I think HiveSessionCatalog should override both buildinFunctionExists and externalFunctionExists. Like:

override def buildinFunctionExists(name: FunctionIdentifier): Boolean = {
   super.buildinFunctionExists(name) || hiveFunctions.contains(name.funcName)
}
override def externalFunctionExists(name: FunctionIdentifier): Boolean = functionExists(name) = {
  super.externalFunctionExists(name)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WeichenXu123 thanks very much for reviewing. I am a little confused. So HiveSessionCatalog's builtinFunctionExists is essentially same as its parent. That is the reason i didn't override it in HiveSessionCatalog. However the logic to lookup an external function is different in HiveSessionCatalog as we also have to handle the special function "histogram_numeric". Thats why i choose to override the externalFunctionExists. One clarification is that builtinFunctionExists solely looks at FunctionRegistry to lookup a function.

  1. builtInFunctionExists => Looks up a function in FunctionRegistry (same for both SessionCatalog and HiveSessionCatalog
  2. externalFunctionExists => Looks up an external catalog to find the function. HiveSessionCatalog has one additional semantics to handle the special function called histogram_numeric.
  3. as you point out, I need to change the override externalFunctionExists to this:
    override def externalFunctionExists(name: FunctionIdentifier): Boolean = { super.externalFunctionExists(name) || hiveFunctions.contains(name.funcName)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, you mean functions like "histogram_numeric" should be regarded as externalFunction in hiveContext ? I am not sure about this. But if that's right your current code is OK :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, seem "histogram_numeric" is not supported in spark natively yet, I think once this jira closed (https://issues.apache.org/jira/browse/SPARK-16280), we don't need these codes in the HiveSessionCatalog.


/** List of functions we pass over to Hive. Note that over time this list should go to 0. */
// We have a list of Hive built-in functions that we do not support. So, we will check
// Hive's function registry and lazily load needed functions into our own function registry.
Expand Down