rdblue commented on code in PR #5134:
URL: https://github.com/apache/iceberg/pull/5134#discussion_r907831386


##########
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java:
##########
@@ -270,6 +278,23 @@ public final void initialize(String name, 
CaseInsensitiveStringMap options) {
     this.createOrcAsIceberg = options.getBoolean("orc-enabled", 
createOrcAsIceberg);
   }
 
+  private void validateHmsUri(String catalogHmsUri) {
+    if (catalogHmsUri == null) {
+      return;
+    }
+
+    Configuration conf = SparkSession.active().sessionState().newHadoopConf();
+    String envHmsUri = conf.get(HiveConf.ConfVars.METASTOREURIS.varname, null);
+    if (envHmsUri == null) {
+      return;
+    }
+
+    Preconditions.checkArgument(catalogHmsUri.equals(envHmsUri),
+        "The environment Hive metastore uri(%s) doesn't match with Spark 
session catalog uri(%s). " +
+            "Please make sure they are the same, or keep a valid one and unset 
the other.",

Review Comment:
   We normally try to keep error messages short and only include tips for 
resolving problems if they aren't obvious. Here, I'd recommend: `"Inconsistent 
Hive metastore URIs: %s (Spark session) != %s (spark_catalog)", envHmsUri, 
catalogHmsUri`



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to