### Question:
HiveCatalog extends BaseMetastoreCatalog implements Closeable, SupportsNamespaces { @Override public boolean dropTable(TableIdentifier identifier, boolean purge) { if (!isValidIdentifier(identifier)) { return false; } String database = identifier.namespace().level(0); TableOperations ops = newTableOps(identifier); TableMetadata lastMetadata; if (purge && ops.current() != null) { lastMetadata = ops.current(); } else { lastMetadata = null; } try { clients.run(client -> { client.dropTable(database, identifier.name(), false , false ); return null; }); if (purge && lastMetadata != null) { CatalogUtil.dropTableData(ops.io(), lastMetadata); } LOG.info("Dropped table: {}", identifier); return true; } catch (NoSuchTableException | NoSuchObjectException e) { LOG.info("Skipping drop, table does not exist: {}", identifier, e); return false; } catch (TException e) { throw new RuntimeException("Failed to drop " + identifier, e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("Interrupted in call to dropTable", e); } } HiveCatalog(Configuration conf);  HiveCatalog(String name, String uri, int clientPoolSize, Configuration conf); @Override List<TableIdentifier> listTables(Namespace namespace); @Override String name(); @Override boolean dropTable(TableIdentifier identifier, boolean purge); @Override void renameTable(TableIdentifier from, TableIdentifier originalTo); @Override void createNamespace(Namespace namespace, Map<String, String> meta); @Override List<Namespace> listNamespaces(Namespace namespace); @Override boolean dropNamespace(Namespace namespace); @Override boolean setProperties(Namespace namespace,  Map<String, String> properties); @Override boolean removeProperties(Namespace namespace,  Set<String> properties); @Override Map<String, String> loadNamespaceMetadata(Namespace namespace); @Override TableOperations newTableOps(TableIdentifier tableIdentifier); @Override void close(); @Override String toString();  }### Answer:
@Test public void testCreateTableDefaultSortOrder() { Schema schema = new Schema( required(1, "id", Types.IntegerType.get(), "unique ID"), required(2, "data", Types.StringType.get()) ); PartitionSpec spec = PartitionSpec.builderFor(schema) .bucket("data", 16) .build(); TableIdentifier tableIdent = TableIdentifier.of(DB_NAME, "tbl"); try { Table table = catalog.createTable(tableIdent, schema, spec); Assert.assertEquals("Order ID must match", 0, table.sortOrder().orderId()); Assert.assertTrue("Order must unsorted", table.sortOrder().isUnsorted()); } finally { catalog.dropTable(tableIdent); } }
@Test public void testCreateTableCustomSortOrder() { Schema schema = new Schema( required(1, "id", Types.IntegerType.get(), "unique ID"), required(2, "data", Types.StringType.get()) ); PartitionSpec spec = PartitionSpec.builderFor(schema) .bucket("data", 16) .build(); SortOrder order = SortOrder.builderFor(schema) .asc("id", NULLS_FIRST) .build(); TableIdentifier tableIdent = TableIdentifier.of(DB_NAME, "tbl"); try { Table table = catalog.buildTable(tableIdent, schema) .withPartitionSpec(spec) .withSortOrder(order) .create(); SortOrder sortOrder = table.sortOrder(); Assert.assertEquals("Order ID must match", 1, sortOrder.orderId()); Assert.assertEquals("Order must have 1 field", 1, sortOrder.fields().size()); Assert.assertEquals("Direction must match ", ASC, sortOrder.fields().get(0).direction()); Assert.assertEquals("Null order must match ", NULLS_FIRST, sortOrder.fields().get(0).nullOrder()); Transform<?, ?> transform = Transforms.identity(Types.IntegerType.get()); Assert.assertEquals("Transform must match", transform, sortOrder.fields().get(0).transform()); } finally { catalog.dropTable(tableIdent); } }