Search in sources :

Example 1 with SamzaSqlDslConverter

use of org.apache.samza.sql.dsl.SamzaSqlDslConverter in project samza by apache.

the class SamzaExecutor method generateResultSchema.

SqlSchema generateResultSchema(Config config) {
    SamzaSqlDslConverter converter = (SamzaSqlDslConverter) new SamzaSqlDslConverterFactory().create(config);
    RelRoot relRoot = converter.convertDsl("").iterator().next();
    List<String> colNames = new ArrayList<>();
    List<String> colTypeNames = new ArrayList<>();
    for (RelDataTypeField dataTypeField : relRoot.validatedRowType.getFieldList()) {
        colNames.add(dataTypeField.getName());
        colTypeNames.add(dataTypeField.getType().toString());
    }
    // in QueryResult class and executeQuery().
    return new SqlSchema(colNames, Collections.emptyList());
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) SamzaSqlDslConverter(org.apache.samza.sql.dsl.SamzaSqlDslConverter) SqlSchema(org.apache.samza.sql.schema.SqlSchema) SamzaSqlDslConverterFactory(org.apache.samza.sql.dsl.SamzaSqlDslConverterFactory) RelRoot(org.apache.calcite.rel.RelRoot)

Aggregations

RelRoot (org.apache.calcite.rel.RelRoot)1 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)1 SamzaSqlDslConverter (org.apache.samza.sql.dsl.SamzaSqlDslConverter)1 SamzaSqlDslConverterFactory (org.apache.samza.sql.dsl.SamzaSqlDslConverterFactory)1 SqlSchema (org.apache.samza.sql.schema.SqlSchema)1