Created
August 28, 2017 18:05
-
-
Save squito/ccd56fefefe4dfef808dc21196a89385 to your computer and use it in GitHub Desktop.
random example of exploring spark internals w/ reflection while debugging cluster config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// paste in | |
// https://gist.githubusercontent.com/squito/329d9cd82a21f645d592/raw/ca9217708293d6fe69ed6638f4feeb3038f8fd9c/reflector.scala | |
val xCat = spark.sessionState.catalog.externalCatalog | |
val catClient = get(xCat, "client") | |
catClient.reflectMethod("getConf", Seq("hive.metastore.uris", "")) | |
import org.apache.hadoop.fs.{FileSystem, Path} | |
val fs = FileSystem.get(sc.hadoopConfiguration) | |
val defaultDb = catClient.reflectMethod("getDatabase", Seq("default")) | |
val dbLoc = defaultDb.reflectField("locationUri").asInstanceOf[java.net.URI] | |
val qDbLoc = xCat.reflectMethod("org$apache$spark$sql$hive$HiveExternalCatalog$$makeQualified", Seq(dbLoc)).asInstanceOf[java.net.URI] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment