You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by chrisr123 <ch...@gmail.com> on 2018/08/19 12:42:20 UTC

Error on SQL orderBy Error

Use Case:
I have a CSV file with data that I want to do a SELECT with orderBy.
I'm getting this error below. What am I doing incorrectly? Thanks!

*Expression (('id).asc).asc failed on input check: Sort should only based on
field reference
*

*Input File structure:*
id,order_date,amount,customer_id
3000,2018-04-19,192.74,1005
3001,2017-08-18,432.87,1000
3002,2018-08-18,22.19,1002

*Source code:*
CsvTableSource orderTableSource = CsvTableSource.builder()
	    .path("input/batch/orders.csv")
	    .ignoreFirstLine()
	    .fieldDelimiter(",")
	    .field("id", Types.INT())
	    .field("order_date", Types.SQL_DATE())
	    .field("amount", Types.DECIMAL())
	    .field("customer_id", Types.LONG())
	    .build();


tableEnv.registerTableSource("orders", orderTableSource);
Table orderTable = tableEnv.scan("orders");

// SELECT *
// FROM orders
Table allOrders = orderTable
	.select("id,order_date,amount,customer_id")
	.orderBy("id.asc");



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/

Re: Error on SQL orderBy Error

Posted by Rong Rong <wa...@gmail.com>.
Filed https://issues.apache.org/jira/browse/FLINK-10172. Seems like it is
affecting latest version.

--
Rong

On Sun, Aug 19, 2018 at 8:14 AM Rong Rong <wa...@gmail.com> wrote:

> Hi Chris,
>
> This looks like a bug to me as
> val allOrders:Table = orderTable
>         .select('id, 'order_date, 'amount, 'customer_id)
>         .orderBy('id.asc)
>
> works perfectly fine. Could you file a bug report and kindly provide the
> Flink version you are using? I can take a look into it
>
> Thanks,
> Rong
>
> On Sun, Aug 19, 2018 at 5:42 AM chrisr123 <ch...@gmail.com> wrote:
>
>> Use Case:
>> I have a CSV file with data that I want to do a SELECT with orderBy.
>> I'm getting this error below. What am I doing incorrectly? Thanks!
>>
>> *Expression (('id).asc).asc failed on input check: Sort should only based
>> on
>> field reference
>> *
>>
>> *Input File structure:*
>> id,order_date,amount,customer_id
>> 3000,2018-04-19,192.74,1005
>> 3001,2017-08-18,432.87,1000
>> 3002,2018-08-18,22.19,1002
>>
>> *Source code:*
>> CsvTableSource orderTableSource = CsvTableSource.builder()
>>             .path("input/batch/orders.csv")
>>             .ignoreFirstLine()
>>             .fieldDelimiter(",")
>>             .field("id", Types.INT())
>>             .field("order_date", Types.SQL_DATE())
>>             .field("amount", Types.DECIMAL())
>>             .field("customer_id", Types.LONG())
>>             .build();
>>
>>
>> tableEnv.registerTableSource("orders", orderTableSource);
>> Table orderTable = tableEnv.scan("orders");
>>
>> // SELECT *
>> // FROM orders
>> Table allOrders = orderTable
>>         .select("id,order_date,amount,customer_id")
>>         .orderBy("id.asc");
>>
>>
>>
>> --
>> Sent from:
>> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
>>
>

Re: Error on SQL orderBy Error

Posted by Rong Rong <wa...@gmail.com>.
Hi Chris,

This looks like a bug to me as
val allOrders:Table = orderTable
        .select('id, 'order_date, 'amount, 'customer_id)
        .orderBy('id.asc)

works perfectly fine. Could you file a bug report and kindly provide the
Flink version you are using? I can take a look into it

Thanks,
Rong

On Sun, Aug 19, 2018 at 5:42 AM chrisr123 <ch...@gmail.com> wrote:

> Use Case:
> I have a CSV file with data that I want to do a SELECT with orderBy.
> I'm getting this error below. What am I doing incorrectly? Thanks!
>
> *Expression (('id).asc).asc failed on input check: Sort should only based
> on
> field reference
> *
>
> *Input File structure:*
> id,order_date,amount,customer_id
> 3000,2018-04-19,192.74,1005
> 3001,2017-08-18,432.87,1000
> 3002,2018-08-18,22.19,1002
>
> *Source code:*
> CsvTableSource orderTableSource = CsvTableSource.builder()
>             .path("input/batch/orders.csv")
>             .ignoreFirstLine()
>             .fieldDelimiter(",")
>             .field("id", Types.INT())
>             .field("order_date", Types.SQL_DATE())
>             .field("amount", Types.DECIMAL())
>             .field("customer_id", Types.LONG())
>             .build();
>
>
> tableEnv.registerTableSource("orders", orderTableSource);
> Table orderTable = tableEnv.scan("orders");
>
> // SELECT *
> // FROM orders
> Table allOrders = orderTable
>         .select("id,order_date,amount,customer_id")
>         .orderBy("id.asc");
>
>
>
> --
> Sent from:
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
>