Skip to content
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 @@ -22,15 +22,13 @@
import java.util.Map;
import org.apache.iceberg.HasTableOperations;
import org.apache.iceberg.Table;
import org.apache.iceberg.hive.HiveTableOperations;
import org.apache.iceberg.spark.Spark3Util;
import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;
import org.apache.spark.sql.catalyst.parser.ParseException;
import org.apache.spark.sql.functions;
import org.apache.spark.sql.types.DataTypes;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand All @@ -55,10 +53,6 @@ public void dropTables() {

@Test
public void testRegisterTable() throws NoSuchTableException, ParseException {
Copy link
Member

Choose a reason for hiding this comment

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

So we aren't actually adding any more tests here we are just removing this Assume clause?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.
Already API level test is there for each catalog for register table.
Configuring other catalogs in this test case is hard (like Glue, REST). It is better to keep them as integration tests (may in in a follow up PR)

Now removing this check will make sure that this testcase runs for hadoop, hive, spark catalog.

Copy link
Member

Choose a reason for hiding this comment

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

How do we Register a table in Hadoop? That doesn't sound possible

Copy link
Member Author

Choose a reason for hiding this comment

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

HadoopCatalog also extends BaseMetastoreCatalog

So, when a register table is called. It makes a fresh commit to the Hadoop catalog too (file name will be as per hadoop catalog)
https://github.com/apache/iceberg/blob/master/core/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java#L84

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

OK Got it, Still not sure I think that was a good idea but it's already in.

Assume.assumeTrue(
"Register only implemented on Hive Catalogs",
spark.conf().get("spark.sql.catalog." + catalogName + ".type").equals("hive"));

long numRows = 1000;

sql("CREATE TABLE %s (id int, data string) using ICEBERG", tableName);
Expand All @@ -72,8 +66,7 @@ public void testRegisterTable() throws NoSuchTableException, ParseException {
long originalFileCount = (long) scalarSql("SELECT COUNT(*) from %s.files", tableName);
long currentSnapshotId = table.currentSnapshot().snapshotId();
String metadataJson =
((HiveTableOperations) (((HasTableOperations) table).operations()))
.currentMetadataLocation();
(((HasTableOperations) table).operations()).current().metadataFileLocation();

List<Object[]> result =
sql("CALL %s.system.register_table('%s', '%s')", catalogName, targetName, metadataJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
import java.util.Map;
import org.apache.iceberg.HasTableOperations;
import org.apache.iceberg.Table;
import org.apache.iceberg.hive.HiveTableOperations;
import org.apache.iceberg.spark.Spark3Util;
import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;
import org.apache.spark.sql.catalyst.parser.ParseException;
import org.apache.spark.sql.functions;
import org.apache.spark.sql.types.DataTypes;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand All @@ -55,10 +53,6 @@ public void dropTables() {

@Test
public void testRegisterTable() throws NoSuchTableException, ParseException {
Assume.assumeTrue(
"Register only implemented on Hive Catalogs",
spark.conf().get("spark.sql.catalog." + catalogName + ".type").equals("hive"));

long numRows = 1000;

sql("CREATE TABLE %s (id int, data string) using ICEBERG", tableName);
Expand All @@ -72,8 +66,7 @@ public void testRegisterTable() throws NoSuchTableException, ParseException {
long originalFileCount = (long) scalarSql("SELECT COUNT(*) from %s.files", tableName);
long currentSnapshotId = table.currentSnapshot().snapshotId();
String metadataJson =
((HiveTableOperations) (((HasTableOperations) table).operations()))
.currentMetadataLocation();
(((HasTableOperations) table).operations()).current().metadataFileLocation();

List<Object[]> result =
sql("CALL %s.system.register_table('%s', '%s')", catalogName, targetName, metadataJson);
Expand Down