Skip to content

Commit

Permalink
Move testCreateExternalTableWithInaccessibleSchemaLocation to TestExt…
Browse files Browse the repository at this point in the history
…ernalHiveTable
  • Loading branch information
findepi committed Jul 22, 2020
1 parent 8472b62 commit 9be344c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
*/
package io.prestosql.tests.hive;

import com.google.inject.Inject;
import io.prestosql.tempto.ProductTest;
import io.prestosql.tempto.Requirement;
import io.prestosql.tempto.RequirementsProvider;
import io.prestosql.tempto.configuration.Configuration;
import io.prestosql.tempto.fulfillment.table.TableInstance;
import io.prestosql.tempto.hadoop.hdfs.HdfsClient;
import org.testng.annotations.Test;

import static io.prestosql.tempto.Requirements.compose;
Expand All @@ -27,17 +29,24 @@
import static io.prestosql.tempto.fulfillment.table.TableRequirements.mutableTable;
import static io.prestosql.tempto.fulfillment.table.hive.tpch.TpchTableDefinitions.NATION;
import static io.prestosql.tempto.query.QueryExecutor.query;
import static io.prestosql.tests.TestGroups.HIVE_WITH_EXTERNAL_WRITES;
import static io.prestosql.tests.TestGroups.PROFILE_SPECIFIC_TESTS;
import static io.prestosql.tests.hive.HiveTableDefinitions.NATION_PARTITIONED_BY_BIGINT_REGIONKEY;
import static io.prestosql.tests.hive.HiveTableDefinitions.NATION_PARTITIONED_BY_REGIONKEY_NUMBER_OF_LINES_PER_SPLIT;
import static io.prestosql.tests.utils.QueryExecutors.onHive;
import static io.prestosql.tests.utils.QueryExecutors.onPresto;
import static java.lang.String.format;

public class TestExternalHiveTable
extends ProductTest
implements RequirementsProvider
{
private static final String HIVE_CATALOG_WITH_EXTERNAL_WRITES = "hive_with_external_writes";
private static final String EXTERNAL_TABLE_NAME = "target_table";

@Inject
private HdfsClient hdfsClient;

@Override
public Requirement getRequirements(Configuration configuration)
{
Expand Down Expand Up @@ -127,6 +136,21 @@ public void testDeleteFromExternalPartitionedTableTable()
assertThat(onPresto().executeQuery("SELECT * FROM " + EXTERNAL_TABLE_NAME)).hasRowsCount(0);
}

@Test(groups = {HIVE_WITH_EXTERNAL_WRITES, PROFILE_SPECIFIC_TESTS})
public void testCreateExternalTableWithInaccessibleSchemaLocation()
{
String schema = "schema_without_location";
String schemaLocation = "/tmp/" + schema;
hdfsClient.createDirectory(schemaLocation);
query(format("CREATE SCHEMA %s.%s WITH (location='%s')", HIVE_CATALOG_WITH_EXTERNAL_WRITES, schema, schemaLocation));

hdfsClient.delete(schemaLocation);

String table = "test_create_external";
String tableLocation = "/tmp/" + table;
query(format("CREATE TABLE %s.%s.%s WITH (external_location = '%s') AS SELECT * FROM tpch.tiny.nation", HIVE_CATALOG_WITH_EXTERNAL_WRITES, schema, table, tableLocation));
}

private void insertNationPartition(TableInstance<?> nation, int partition)
{
onHive().executeQuery(
Expand Down

This file was deleted.

0 comments on commit 9be344c

Please sign in to comment.