You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/08/06 10:36:40 UTC
[GitHub] [spark] MaxGekk opened a new pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
MaxGekk opened a new pull request #29377:
URL: https://github.com/apache/spark/pull/29377
### What changes were proposed in this pull request?
Get table names directly from a sequence of Hive tables in `HiveClientImpl.listTablesByType()` by skipping conversions Hive tables to Catalog tables.
### Why are the changes needed?
A Hive metastore can be shared across many clients. A client can create tables using a SerDe which is not available on other clients, for instance `ROW FORMAT SERDE "com.ibm.spss.hive.serde2.xml.XmlSerDe"`. In the current implementation, other clients get the following exception while getting views:
```
java.lang.RuntimeException: MetaException(message:java.lang.ClassNotFoundException Class com.ibm.spss.hive.serde2.xml.XmlSerDe not found)
```
when `com.ibm.spss.hive.serde2.xml.XmlSerDe` is not available.
### Does this PR introduce _any_ user-facing change?
Yes. For example, `SHOW VIEWS` returns a list of views instead of throwing an exception.
### How was this patch tested?
- By existing test suites like:
```
$ build/sbt -Phive-2.3 "test:testOnly org.apache.spark.sql.hive.client.VersionsSuite"
```
- And manually:
1. Build Spark with Hive 1.2: `./build/sbt package -Phive-1.2 -Phive -Dhadoop.version=2.8.5`
2. Run spark-shell with a custom Hive SerDe, for instance download [json-serde-1.3.8-jar-with-dependencies.jar](https://github.com/cdamak/Twitter-Hive/blob/master/json-serde-1.3.8-jar-with-dependencies.jar) from https://github.com/cdamak/Twitter-Hive:
```
$ ./bin/spark-shell --jars ../Downloads/json-serde-1.3.8-jar-with-dependencies.jar
```
3. Create a Hive table using this SerDe:
```scala
scala> :paste
// Entering paste mode (ctrl-D to finish)
sql(s"""
|CREATE TABLE json_table2(page_id INT NOT NULL)
|ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
|""".stripMargin)
// Exiting paste mode, now interpreting.
res0: org.apache.spark.sql.DataFrame = []
scala> sql("SHOW TABLES").show
+--------+-----------+-----------+
|database| tableName|isTemporary|
+--------+-----------+-----------+
| default|json_table2| false|
+--------+-----------+-----------+
scala> sql("SHOW VIEWS").show
+---------+--------+-----------+
|namespace|viewName|isTemporary|
+---------+--------+-----------+
+---------+--------+-----------+
```
4. Quit from the current `spark-shell` and run it without jars:
```
$ ./bin/spark-shell
```
5. Show views. Without the fix, it throws the exception:
```scala
scala> sql("SHOW VIEWS").show
20/08/06 10:53:36 ERROR log: error in initSerDe: java.lang.ClassNotFoundException Class org.openx.data.jsonserde.JsonSerDe not found
java.lang.ClassNotFoundException: Class org.openx.data.jsonserde.JsonSerDe not found
at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2273)
at org.apache.hadoop.hive.metastore.MetaStoreUtils.getDeserializer(MetaStoreUtils.java:385)
at org.apache.hadoop.hive.ql.metadata.Table.getDeserializerFromMetaStore(Table.java:276)
at org.apache.hadoop.hive.ql.metadata.Table.getDeserializer(Table.java:258)
at org.apache.hadoop.hive.ql.metadata.Table.getCols(Table.java:605)
```
After the fix:
```scala
scala> sql("SHOW VIEWS").show
+---------+--------+-----------+
|namespace|viewName|isTemporary|
+---------+--------+-----------+
+---------+--------+-----------+
```
Authored-by: Max Gekk <ma...@gmail.com>
Signed-off-by: Wenchen Fan <we...@databricks.com>
(cherry picked from commit dc96f2f8d6e08c4bc30bc11d6b29109d2aeb604b)
Signed-off-by: Max Gekk <ma...@gmail.com>
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669928234
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan closed pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #29377:
URL: https://github.com/apache/spark/pull/29377
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669927960
thanks, merging to 3.0!
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669928234
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669851830
**[Test build #127136 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127136/testReport)** for PR 29377 at commit [`9f3bda9`](https://github.com/apache/spark/commit/9f3bda9bb8d09c429fd8fb6eefcddc06b50dd9b9).
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669852243
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669852243
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #29377:
URL: https://github.com/apache/spark/pull/29377#discussion_r466469201
##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
##########
@@ -759,15 +759,17 @@ private[hive] class HiveClientImpl(
dbName: String,
pattern: String,
tableType: CatalogTableType): Seq[String] = withHiveState {
+ val hiveTableType = toHiveTableType(tableType)
try {
// Try with Hive API getTablesByType first, it's supported from Hive 2.3+.
- shim.getTablesByType(client, dbName, pattern, toHiveTableType(tableType))
+ shim.getTablesByType(client, dbName, pattern, hiveTableType)
} catch {
case _: UnsupportedOperationException =>
// Fallback to filter logic if getTablesByType not supported.
val tableNames = client.getTablesByPattern(dbName, pattern).asScala
- val tables = getTablesByName(dbName, tableNames).filter(_.tableType == tableType)
Review comment:
It's fine if we 'break' Scala 2.13 a bit in master while we're still getting it working, if it makes it easier to not reason about it. If you carry back to .toSeq / .toMap-style changes into 3.0 it's fine though, still works
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] MaxGekk commented on a change in pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #29377:
URL: https://github.com/apache/spark/pull/29377#discussion_r466341744
##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
##########
@@ -759,15 +759,17 @@ private[hive] class HiveClientImpl(
dbName: String,
pattern: String,
tableType: CatalogTableType): Seq[String] = withHiveState {
+ val hiveTableType = toHiveTableType(tableType)
try {
// Try with Hive API getTablesByType first, it's supported from Hive 2.3+.
- shim.getTablesByType(client, dbName, pattern, toHiveTableType(tableType))
+ shim.getTablesByType(client, dbName, pattern, hiveTableType)
} catch {
case _: UnsupportedOperationException =>
// Fallback to filter logic if getTablesByType not supported.
val tableNames = client.getTablesByPattern(dbName, pattern).asScala
- val tables = getTablesByName(dbName, tableNames).filter(_.tableType == tableType)
Review comment:
Here is the fix for master https://github.com/apache/spark/pull/29379
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669851830
**[Test build #127136 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127136/testReport)** for PR 29377 at commit [`9f3bda9`](https://github.com/apache/spark/commit/9f3bda9bb8d09c429fd8fb6eefcddc06b50dd9b9).
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29377:
URL: https://github.com/apache/spark/pull/29377#issuecomment-669926926
**[Test build #127136 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127136/testReport)** for PR 29377 at commit [`9f3bda9`](https://github.com/apache/spark/commit/9f3bda9bb8d09c429fd8fb6eefcddc06b50dd9b9).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] MaxGekk commented on a change in pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #29377:
URL: https://github.com/apache/spark/pull/29377#discussion_r466324216
##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
##########
@@ -759,15 +759,17 @@ private[hive] class HiveClientImpl(
dbName: String,
pattern: String,
tableType: CatalogTableType): Seq[String] = withHiveState {
+ val hiveTableType = toHiveTableType(tableType)
try {
// Try with Hive API getTablesByType first, it's supported from Hive 2.3+.
- shim.getTablesByType(client, dbName, pattern, toHiveTableType(tableType))
+ shim.getTablesByType(client, dbName, pattern, hiveTableType)
} catch {
case _: UnsupportedOperationException =>
// Fallback to filter logic if getTablesByType not supported.
val tableNames = client.getTablesByPattern(dbName, pattern).asScala
- val tables = getTablesByName(dbName, tableNames).filter(_.tableType == tableType)
Review comment:
Master's patch conflicts with branch-3.0 because of different base line:
- master: tableNames.toSeq
- branch-3.0: tableNames
Not on purpose but I removed @srowen 's changes https://github.com/apache/spark/commit/c28a6fa5112c9ba3839f52b737266f24fdfcf75b#diff-6fd847124f8eae45ba2de1cf7d6296feR769 . I will prepare a follow up PR for master.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] MaxGekk commented on a change in pull request #29377: [SPARK-32546][SQL][3.0] Get table names directly from Hive tables
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #29377:
URL: https://github.com/apache/spark/pull/29377#discussion_r466324216
##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
##########
@@ -759,15 +759,17 @@ private[hive] class HiveClientImpl(
dbName: String,
pattern: String,
tableType: CatalogTableType): Seq[String] = withHiveState {
+ val hiveTableType = toHiveTableType(tableType)
try {
// Try with Hive API getTablesByType first, it's supported from Hive 2.3+.
- shim.getTablesByType(client, dbName, pattern, toHiveTableType(tableType))
+ shim.getTablesByType(client, dbName, pattern, hiveTableType)
} catch {
case _: UnsupportedOperationException =>
// Fallback to filter logic if getTablesByType not supported.
val tableNames = client.getTablesByPattern(dbName, pattern).asScala
- val tables = getTablesByName(dbName, tableNames).filter(_.tableType == tableType)
Review comment:
Master's patch conflicts with branch-3.0 because of different base line:
- master: tableNames.toSeq
- branch-3.0: tableNames
Not on purpose but I removed @srowen 's changes https://github.com/apache/spark/commit/c28a6fa5112c9ba3839f52b737266f24fdfcf75b#diff-6fd847124f8eae45ba2de1cf7d6296feR769 . I have realised that when I tried to cherry-pick the changes to branch-3.0. I will prepare a follow up PR for master.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org