use of org.apache.spark.sql.catalyst.analysis.UnresolvedRelation in project kylo by Teradata.
the class AbstractHiveDataSetProviderTest method write.
/**
* Verify writing to a Hive table.
*/
@Test
public void write() {
// Mock writer
writer = createDataFrameWriter(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
final InsertIntoTable plan = invocation.getArgumentAt(0, InsertIntoTable.class);
final UnresolvedRelation relation = (UnresolvedRelation) plan.table();
Assert.assertEquals("default", relation.tableIdentifier().database().get());
Assert.assertEquals("mytable", relation.tableIdentifier().table());
return null;
}
});
// Create options
final DataSetOptions options = new DataSetOptions();
options.addJar("http://example.com/serde.jar");
options.setOption(KyloCatalogConstants.PATH_OPTION, "default.mytable");
// Test writing
final MockHiveDataSetProvider provider = new MockHiveDataSetProvider();
provider.write(Mockito.mock(KyloCatalogClient.class), options, Mockito.mock(DataFrame.class));
Mockito.verify(sqlContext).sql("ADD JAR http://example.com/serde.jar");
Mockito.verify(sqlContext).executePlan(Mockito.any(LogicalPlan.class));
}
Aggregations