Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark 3.3, 3.4: Fix incorrect catalog loaded in TestCreateActions #11049

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public void before() {
public void after() throws IOException {
// Drop the hive table.
spark.sql(String.format("DROP TABLE IF EXISTS %s", baseTableName));
spark.sessionState().catalogManager().reset();
spark.conf().unset("spark.sql.catalog.spark_catalog.type");
spark.conf().unset("spark.sql.catalog.spark_catalog.default-namespace");
spark.conf().unset("spark.sql.catalog.spark_catalog.parquet-enabled");
spark.conf().unset("spark.sql.catalog.spark_catalog.cache-enabled");
}

@Test
Expand Down Expand Up @@ -728,6 +733,8 @@ public void testStructOfThreeLevelLists() throws Exception {

@Test
public void testTwoLevelList() throws IOException {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", true);

String tableName = sourceName("testTwoLevelList");
Expand Down Expand Up @@ -811,6 +818,8 @@ public boolean accept(File dir, String name) {
}

private void threeLevelList(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName = sourceName(String.format("threeLevelList_%s", useLegacyMode));
Expand All @@ -833,6 +842,8 @@ private void threeLevelList(boolean useLegacyMode) throws Exception {
}

private void threeLevelListWithNestedStruct(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName =
Expand All @@ -858,6 +869,8 @@ private void threeLevelListWithNestedStruct(boolean useLegacyMode) throws Except
}

private void threeLevelLists(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName = sourceName(String.format("threeLevelLists_%s", useLegacyMode));
Expand Down Expand Up @@ -885,6 +898,8 @@ private void threeLevelLists(boolean useLegacyMode) throws Exception {
}

private void structOfThreeLevelLists(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName = sourceName(String.format("structOfThreeLevelLists_%s", useLegacyMode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public void before() {
public void after() throws IOException {
// Drop the hive table.
spark.sql(String.format("DROP TABLE IF EXISTS %s", baseTableName));
spark.sessionState().catalogManager().reset();
spark.conf().unset("spark.sql.catalog.spark_catalog.type");
spark.conf().unset("spark.sql.catalog.spark_catalog.default-namespace");
spark.conf().unset("spark.sql.catalog.spark_catalog.parquet-enabled");
spark.conf().unset("spark.sql.catalog.spark_catalog.cache-enabled");
}

@Test
Expand Down Expand Up @@ -728,6 +733,8 @@ public void testStructOfThreeLevelLists() throws Exception {

@Test
public void testTwoLevelList() throws IOException {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use Assumptions from AssertJ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These two tests haven't been converted to AssertJ yet.


spark.conf().set("spark.sql.parquet.writeLegacyFormat", true);

String tableName = sourceName("testTwoLevelList");
Expand Down Expand Up @@ -811,6 +818,8 @@ public boolean accept(File dir, String name) {
}

private void threeLevelList(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName = sourceName(String.format("threeLevelList_%s", useLegacyMode));
Expand All @@ -833,6 +842,8 @@ private void threeLevelList(boolean useLegacyMode) throws Exception {
}

private void threeLevelListWithNestedStruct(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName =
Expand All @@ -858,6 +869,8 @@ private void threeLevelListWithNestedStruct(boolean useLegacyMode) throws Except
}

private void threeLevelLists(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName = sourceName(String.format("threeLevelLists_%s", useLegacyMode));
Expand Down Expand Up @@ -885,6 +898,8 @@ private void threeLevelLists(boolean useLegacyMode) throws Exception {
}

private void structOfThreeLevelLists(boolean useLegacyMode) throws Exception {
Assume.assumeTrue("Cannot migrate to a hadoop based catalog", !type.equals("hadoop"));

spark.conf().set("spark.sql.parquet.writeLegacyFormat", useLegacyMode);

String tableName = sourceName(String.format("structOfThreeLevelLists_%s", useLegacyMode));
Expand Down