Tao Li created BEAM-11930:
-----------------------------

             Summary: Bug with "over window" query from Beam SQL
                 Key: BEAM-11930
                 URL: https://issues.apache.org/jira/browse/BEAM-11930
             Project: Beam
          Issue Type: Bug
          Components: sdk-java-core
            Reporter: Tao Li


The problem is that I don’t see the alias column “agg” in the query result's 
schema. 

This is my code (with Beam 2.28):
 {noformat}
        Schema appSchema = Schema
                .builder()
                .addInt32Field("foo")
                .addInt32Field("bar")
                .build();
 
        Row rowOne = Row.withSchema(appSchema).addValues(1, 1).build();
        Row rowTwo = Row.withSchema(appSchema).addValues(1, 2).build();
 
        PCollection<Row> inputRows = pipeline
                .apply(Create.of(rowOne, rowTwo))
                .setRowSchema(appSchema);
 
        String sql = "SELECT foo, bar, RANK() over (PARTITION BY foo ORDER BY 
bar) AS agg FROM PCOLLECTION";
        PCollection<Row> result  = inputRows.apply("sql", 
SqlTransform.query(sql));
 
{noformat}

The Beam schema of the query result is below. Row name is "w0$o0" instead of my 
specified name "agg".
 
Field{name=foo, description=, type=FieldType{typeName=INT32, nullable=false, 
logicalType=null, collectionElementType=null, mapKeyType=null, 
mapValueType=null, rowSchema=null, metadata={}}, options={{}}}
Field{name=bar, description=, type=FieldType{typeName=INT32, nullable=false, 
logicalType=null, collectionElementType=null, mapKeyType=null, 
mapValueType=null, rowSchema=null, metadata={}}, options={{}}}
Field{name=w0$o0, description=, type=FieldType{typeName=INT64, nullable=false, 
logicalType=null, collectionElementType=null, mapKeyType=null, 
mapValueType=null, rowSchema=null, metadata={}}, options={{}}}
 





--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to