Search in sources :

Example 11 with TransformRequest

use of com.thinkbiganalytics.spark.rest.model.TransformRequest in project kylo by Teradata.

the class TransformServiceTest method toScriptWithParent.

/**
 * Verify converting a transformation request with a parent to a Scala script.
 */
@Test
public void toScriptWithParent() throws Exception {
    // Build the request
    final TransformRequest.Parent parent = new TransformRequest.Parent();
    parent.setScript("sqlContext.range(1,10)");
    parent.setTable("parent_table");
    final TransformRequest request = new TransformRequest();
    request.setParent(parent);
    request.setScript("parent.withColumn(functions.expr(\"id+1\")");
    // Test converting request to script
    final TransformService service = new TransformService(TransformScript.class, Mockito.mock(SparkScriptEngine.class), Mockito.mock(SparkContextService.class), Mockito.mock(JobTrackerService.class));
    InputStream inputStream = getClass().getResourceAsStream("transform-service-script2.scala");
    final String expected = IOUtils.toString(inputStream, "UTF-8");
    Assert.assertEquals(expected, service.toScript(request));
}
Also used : InputStream(java.io.InputStream) SparkContextService(com.thinkbiganalytics.spark.SparkContextService) SparkScriptEngine(com.thinkbiganalytics.spark.repl.SparkScriptEngine) TransformRequest(com.thinkbiganalytics.spark.rest.model.TransformRequest) Test(org.junit.Test)

Example 12 with TransformRequest

use of com.thinkbiganalytics.spark.rest.model.TransformRequest in project kylo by Teradata.

the class SparkFileSchemaParserService method createTransformRequest.

// Port: 8450
private TransformRequest createTransformRequest(File localFile, SparkFileType fileType) {
    TransformRequest transformRequest = new TransformRequest();
    transformRequest.setScript(toScript(localFile, fileType));
    return transformRequest;
}
Also used : TransformRequest(com.thinkbiganalytics.spark.rest.model.TransformRequest)

Aggregations

TransformRequest (com.thinkbiganalytics.spark.rest.model.TransformRequest)12 Test (org.junit.Test)9 TransformResponse (com.thinkbiganalytics.spark.rest.model.TransformResponse)8 Response (javax.ws.rs.core.Response)5 SparkContextService (com.thinkbiganalytics.spark.SparkContextService)4 SparkScriptEngine (com.thinkbiganalytics.spark.repl.SparkScriptEngine)4 InputStream (java.io.InputStream)4 DataSet (com.thinkbiganalytics.spark.DataSet)2 SaveResponse (com.thinkbiganalytics.spark.rest.model.SaveResponse)2 TransformService (com.thinkbiganalytics.spark.service.TransformService)2 List (java.util.List)2 SparkContext (org.apache.spark.SparkContext)2 StructType (org.apache.spark.sql.types.StructType)2 StorageLevel (org.apache.spark.storage.StorageLevel)2 NamedParam (scala.tools.nsc.interpreter.NamedParam)2 Response (com.jayway.restassured.response.Response)1 Profiler (com.thinkbiganalytics.spark.dataprofiler.Profiler)1 SaveSqlStage (com.thinkbiganalytics.spark.metadata.SaveSqlStage)1 SaveResult (com.thinkbiganalytics.spark.model.SaveResult)1 Datasource (com.thinkbiganalytics.spark.rest.model.Datasource)1