use of org.apache.spark.sql.catalyst.analysis.Catalog in project kylo by Teradata.
the class AbstractHiveDataSetProviderTest method createDataFrameWriter.
/**
* Creates a {@code DataFrameWriter} that creates tables using the specified answer.
*/
@Nonnull
private DataFrameWriter createDataFrameWriter(@Nonnull final Answer<Void> executePlanAnswer) {
final DataFrame df = Mockito.mock(DataFrame.class);
Mockito.when(df.sqlContext()).thenReturn(sqlContext);
final Catalog catalog = Mockito.mock(Catalog.class);
Mockito.when(catalog.tableExists(Mockito.any(TableIdentifier.class))).thenReturn(false);
Mockito.when(sqlContext.catalog()).thenReturn(catalog);
final QueryExecution queryExecution = Mockito.mock(QueryExecution.class);
Mockito.when(sqlContext.executePlan(Mockito.any(LogicalPlan.class))).then(new Answer<QueryExecution>() {
@Override
public QueryExecution answer(InvocationOnMock invocation) throws Throwable {
executePlanAnswer.answer(invocation);
return queryExecution;
}
});
return new DataFrameWriter(df);
}
Aggregations