Remove redundant Optional
@@ -24,8 +24,6 @@ import io.prestodb.tempto.fulfillment.table.hive.HiveTableDefinition;
import io.prestodb.tempto.query.QueryExecutor;
import org.testng.annotations.Test;
-import java.util.Optional;
-
import static com.facebook.presto.tests.TestGroups.HIVE_CONNECTOR;
import static com.facebook.presto.tests.utils.QueryExecutors.onHive;
import static io.prestodb.tempto.assertions.QueryAssert.Row.row;
@@ -68,8 +66,8 @@ public class TestHiveBucketedTables
public void testIgnorePartitionBucketingIfNotBucketed()
{
String tableName = mutableTablesState().get(BUCKETED_PARTITIONED_NATION).getNameInDatabase();
- populateDataToHiveTable(tableName, NATION.getName(), Optional.of("part_key = 'insert_1'"));
- populateDataToHiveTable(tableName, NATION.getName(), Optional.of("part_key = 'insert_2'"));
+ populateHivePartitionedTable(tableName, NATION.getName(), "part_key = 'insert_1'");
+ populateHivePartitionedTable(tableName, NATION.getName(), "part_key = 'insert_2'");
testContext().getDependency(QueryExecutor.class, "hive").executeQuery(format("ALTER TABLE %s NOT CLUSTERED", tableName));
@@ -77,12 +75,9 @@ public class TestHiveBucketedTables
.containsExactly(row(2));
}
- private static void populateDataToHiveTable(String destination, String source, Optional<String> partition)
+ private static void populateHivePartitionedTable(String destination, String source, String partition)
{
- String queryStatement = format("INSERT INTO TABLE %s" +
- (partition.isPresent() ? format(" PARTITION (%s) ", partition.get()) : " ") +
- "SELECT * FROM %s",
- destination, source);
+ String queryStatement = format("INSERT INTO TABLE %s PARTITION (%s) SELECT * FROM %s", destination, partition, source);
onHive().executeQuery("set hive.enforce.bucketing = true");
onHive().executeQuery("set hive.enforce.sorting = true");
