Skip to content

Spark: Validate HMS uri in SparkSessionCatalog#5134

Merged
rdblue merged 3 commits intoapache:masterfrom
flyrain:sparksessioncatalog
Jun 28, 2022
Merged

Spark: Validate HMS uri in SparkSessionCatalog#5134
rdblue merged 3 commits intoapache:masterfrom
flyrain:sparksessioncatalog

Conversation

@flyrain
Copy link
Contributor

@flyrain flyrain commented Jun 25, 2022

To close #2488. Open a new PR since #3126 isn't active for a while.
All comments in #3126 are resolved. Please take a look. @RussellSpitzer @rdblue @kbendick @szehon-ho @karuppayya @aokolnychyi

@github-actions github-actions bot added the spark label Jun 25, 2022

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.",
Copy link
Contributor

Choose a reason for hiding this comment

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

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

spark.sessionState().catalogManager().reset();
spark.conf().set(envHmsUriKey, hmsUri);
spark.conf().set(catalogHmsUriKey, "RandomString");
Assert.assertThrows(IllegalArgumentException.class, () -> spark.sessionState().catalogManager().v2SessionCatalog());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this validate the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the new commit.

@rdblue rdblue merged commit c27efc0 into apache:master Jun 28, 2022
@rdblue
Copy link
Contributor

rdblue commented Jun 28, 2022

Thanks, @flyrain!

namrathamyske pushed a commit to namrathamyske/iceberg that referenced this pull request Jul 10, 2022
namrathamyske pushed a commit to namrathamyske/iceberg that referenced this pull request Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forbid setting "uri" for SparkSessionCatalog when Hive is used.

2 participants

Comments