Skip to content

Commit

Permalink
DESC table should show table properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant Singh committed Jun 9, 2022
1 parent 2244ade commit 79dc60c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
package org.apache.iceberg.spark;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.iceberg.Table;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.spark.extensions.SparkExtensionsTestBase;
Expand Down Expand Up @@ -149,6 +151,18 @@ public void testCreateTable() {
Assert.assertEquals("Should be partitioned on 3 columns", 3, third.spec().fields().size());
}

@Test
public void testDescribeTable() {
// create table
sql("CREATE TABLE %s (id bigint, data string) USING iceberg", tableName);
sql("INSERT INTO %s VALUES (1, 'a'), (2, 'b'), (3, 'c')", tableName);
List<Object[]> tblPropRows = sql("DESC TABLE EXTENDED %s", tableName)
.stream().filter(tblPropRow -> tblPropRow[0].equals("Table Properties")).collect(Collectors.toList());

Assert.assertEquals(1, tblPropRows.size());
Assert.assertTrue(String.valueOf(tblPropRows.get(0)[1]).contains("metadata_location="));
}

private Table getTable(String name) {
return validationCatalog.loadTable(TableIdentifier.of("default", name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public Map<String, String> properties() {
if (icebergTable instanceof BaseTable) {
TableOperations ops = ((BaseTable) icebergTable).operations();
propsBuilder.put(FORMAT_VERSION, String.valueOf(ops.current().formatVersion()));
propsBuilder.put("metadata_location", String.valueOf(ops.current().metadataFileLocation()));
}

if (!icebergTable.sortOrder().isUnsorted()) {
Expand Down

0 comments on commit 79dc60c

Please sign in to comment.