juliuszsompolski commented on a change in pull request #29834:
URL: https://github.com/apache/spark/pull/29834#discussion_r495061696
##########
File path:
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetSchemasOperation.scala
##########
@@ -77,7 +77,8 @@ private[hive] class SparkGetSchemasOperation(
val globalTempViewDb =
sqlContext.sessionState.catalog.globalTempViewManager.database
val databasePattern =
Pattern.compile(CLIServiceUtils.patternToRegex(schemaName))
- if (databasePattern.matcher(globalTempViewDb).matches()) {
+ if (schemaName == null || schemaName.isEmpty ||
Review comment:
@cloud-fan
this behaviour is changed by convertSchemaPattern in
https://github.com/apache/hive/blob/14e3f19d027858a6f36ea6d41a3e8e45625f91bf/service/src/java/org/apache/hive/service/cli/operation/MetadataOperation.java#L75
```
if ((pattern == null) || pattern.isEmpty()) {
return convertPattern("%", true);
} else {
return convertPattern(pattern, true);
}
```
it explicitly turns "" into a "%" pattern.
Then we use that to call listDatabases:
```
val schemaPattern = convertSchemaPattern(schemaName)
sqlContext.sessionState.catalog.listDatabases(schemaPattern).foreach {
dbName =>
rowSet.addRow(Array[AnyRef](dbName, DEFAULT_HIVE_CATALOG))
}
```
but then for globalTempViews, we are not using the converted schemaPattern,
but schemaName, which will not treat "" as wildcard.
```
val globalTempViewDb =
sqlContext.sessionState.catalog.globalTempViewManager.database
val databasePattern =
Pattern.compile(CLIServiceUtils.patternToRegex(schemaName))
if (databasePattern.matcher(globalTempViewDb).matches()) {
```
described by @yaooqinn like that, it does seem to be inconsistent behaviour
and just a omission bug: we should treat the pattern for global temp views the
same way... JDBC standard would say that it should not be a wildcard, but Hive
seems to be treating it as wildcard.
Treating it as empty would be consistent with JDBC standard. Treating it as
a wildcard would be a smaller behaviour change, and consistent with Hive.
@bogdanghit @wangyum @AngersZhuuuu what do you think?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]