use of io.confluent.ksql.codegen.CodeGenRunner in project ksql by confluentinc.
the class SelectValueMapperTest method createExpressionMetadata.
private List<ExpressionMetadata> createExpressionMetadata(final List<Pair<String, Expression>> expressionPairList, final Schema schema) throws Exception {
final CodeGenRunner codeGenRunner = new CodeGenRunner(schema, new FunctionRegistry());
final List<ExpressionMetadata> expressionEvaluators = new ArrayList<>();
for (Pair<String, Expression> expressionPair : expressionPairList) {
final ExpressionMetadata expressionEvaluator = codeGenRunner.buildCodeGenFromParseTree(expressionPair.getRight());
expressionEvaluators.add(expressionEvaluator);
}
return expressionEvaluators;
}
use of io.confluent.ksql.codegen.CodeGenRunner in project ksql by confluentinc.
the class SchemaKStream method createSelectValueMapperAndSchema.
Pair<Schema, SelectValueMapper> createSelectValueMapperAndSchema(final List<Pair<String, Expression>> expressionPairList) {
try {
final CodeGenRunner codeGenRunner = new CodeGenRunner(schema, functionRegistry);
final SchemaBuilder schemaBuilder = SchemaBuilder.struct();
final List<ExpressionMetadata> expressionEvaluators = new ArrayList<>();
for (Pair<String, Expression> expressionPair : expressionPairList) {
final ExpressionMetadata expressionEvaluator = codeGenRunner.buildCodeGenFromParseTree(expressionPair.getRight());
schemaBuilder.field(expressionPair.getLeft(), expressionEvaluator.getExpressionType());
expressionEvaluators.add(expressionEvaluator);
}
return new Pair<>(schemaBuilder.build(), new SelectValueMapper(genericRowValueTypeEnforcer, expressionPairList, expressionEvaluators));
} catch (Exception e) {
throw new KsqlException("Code generation failed for SelectValueMapper", e);
}
}
Aggregations