Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jphalip committed Jan 25, 2024
1 parent 3b9b870 commit e8bc548
Showing 1 changed file with 1 addition and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,7 @@ public void testGetTaskWriterOutputFile() {
String writerId = WriterRegistry.getWriterId();
Path path = JobUtils.getTaskWriterOutputFile(conf, jobDetails, taskAttemptID, writerId, "jpeg");
String pattern =
"^/hadoop-tmp/bq-hive-hive-query-id-query123/default.mytable/output/myproject_mydataset_mytable_abcd1234_w\\d+\\.jpeg";
assertThat(path.toString(), matchesPattern(pattern));
}

/**
* Same as {@link #testGetTaskWriterOutputFile} but with the ".hive-staging" directory, when the
* `mapreduce.output.fileoutputformat.outputdir` conf property is set. This happens when using
* Spark SQL.
*/
@Test
public void testGetTaskWriterOutputFileWithHiveStagingDir() {
Configuration conf = new Configuration();
conf.set("hive.query.id", "query123");
conf.set("hadoop.tmp.dir", "/hadoop-tmp/");
conf.set(
"mapreduce.output.fileoutputformat.outputdir", "/abc/def/.hive-staging-xyz/-ext-10000/");
JobDetails jobDetails = new JobDetails();
jobDetails.setTableProperties(new Properties());
jobDetails.getTableProperties().put("name", "default.mytable");
TableId tableId = TableId.of("myproject", "mydataset", "mytable");
jobDetails.setTableId(tableId);
String taskID = "abcd1234";
String writerId = WriterRegistry.getWriterId();
Path path = JobUtils.getTaskWriterOutputFile(conf, jobDetails, taskID, writerId, "jpeg");
String pattern =
"^/hadoop-tmp/bq-hive-hive-query-id-query123/default.mytable/.hive-staging-xyz/-ext-10000/myproject_mydataset_mytable_abcd1234_w\\d+\\.jpeg";
"^/hadoop-tmp/bq-hive-hive-query-id-query123/default.mytable/myproject_mydataset_mytable_abcd1234_w\\d+\\.jpeg";
assertThat(path.toString(), matchesPattern(pattern));
}
}

0 comments on commit e8bc548

Please sign in to comment.