use of org.finos.legend.pure.generated.Root_meta_external_shared_format_ExternalFormatExtension in project legend-engine by finos.
the class TestExternalFormatQueries method runTest.
protected String runTest(PureModelContextData generated, String grammar, String query, String mappingPath, String runtimePath, InputStream input) {
try {
PureModelContextData parsed = PureGrammarParser.newInstance().parseModel(grammar);
PureModelContextData modelData = generated == null ? parsed : parsed.combine(generated);
ObjectMapper objectMapper = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports();
String json = objectMapper.writeValueAsString(modelData);
modelData = objectMapper.readValue(json, PureModelContextData.class);
PureModel model = Compiler.compile(modelData, DeploymentMode.TEST, null);
PureGrammarParser parser = PureGrammarParser.newInstance();
Lambda lambdaProtocol = parser.parseLambda(query, "query", true);
LambdaFunction<?> lambda = HelperValueSpecificationBuilder.buildLambda(lambdaProtocol.body, Lists.fixedSize.<Variable>empty(), model.getContext());
ExecutionContext context = new Root_meta_pure_runtime_ExecutionContext_Impl(" ")._enableConstraints(true);
RichIterable<Root_meta_external_shared_format_ExternalFormatExtension> planGenerationExtensions = LazyIterate.collect(ExternalFormatPlanGenerationExtensionLoader.extensions().values(), ext -> ext.getPureExtension(model.getExecutionSupport()));
RichIterable<? extends Root_meta_pure_router_extension_RouterExtension> extensions = core_external_shared_extension.Root_meta_external_shared_format_routerExtensions_String_1__ExternalFormatExtension_MANY__RouterExtension_MANY_("externalFormat", planGenerationExtensions, model.getExecutionSupport());
Mapping mapping = model.getMapping(mappingPath);
Runtime runtime = model.getRuntime(runtimePath);
String plan = PlanGenerator.generateExecutionPlanAsString(lambda, mapping, runtime, context, model, "vX_X_X", PlanPlatform.JAVA, "test", extensions, LegendPlanTransformers.transformers);
PlanExecutor executor = PlanExecutor.newPlanExecutorWithAvailableStoreExecutors(true);
Result result = executor.execute(plan, input);
StreamingResult streamingResult = (StreamingResult) result;
return streamingResult.flush(streamingResult.getSerializer(SerializationFormat.DEFAULT));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations