You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Homer <lo...@gmail.com> on 2016/09/16 01:02:11 UTC

ORDER BY usage

Hi,

I'm having an issue validating a query (using Calcite 1.8)  with an 
order by statement that doesn't reference columns in the select clause.  
I'm sure the issue is mine in the meta processing but just wanted to 
confirm Calcite should support it.

Simplified example

create table test1 (field1 text, field2 text);

select field1,field2 from test1 order by field2;    ---- this works fine

select field1 from test1 order by field2;   ---- this errors with a 
message like "org.apache.calcite.sql.validate.SqlValidatorException: 
Column 'field2' not found in any table"

Should this syntax be valid in Calcite?

thanks



Re: ORDER BY usage

Posted by Homer <lo...@gmail.com>.
Julian,

Thanks for confirming, I'm sure I must be breaking something somewhere.


On 2016-09-15 06:06 PM, Julian Hyde wrote:
> Surprised this doesn't work. It works for me:
>
> $ ./sqlline
> sqlline> !connect
> jdbc:calcite:model=example/csv/src/test/resources/model.json sa ""
> 0: jdbc:calcite:model=example/csv/src/test/re> select empno from
> sales.emps order by deptno;
> +-------+
> | EMPNO |
> +-------+
> | 100   |
> | 110   |
> | 120   |
> | 110   |
> | 130   |
> +-------+
> 5 rows selected (0.252 seconds)
> 0: jdbc:calcite:model=example/csv/src/test/re>
>
> Julian
>
>
> On Thu, Sep 15, 2016 at 6:02 PM, Homer <lo...@gmail.com> wrote:
>> Hi,
>>
>> I'm having an issue validating a query (using Calcite 1.8)  with an order by
>> statement that doesn't reference columns in the select clause.  I'm sure the
>> issue is mine in the meta processing but just wanted to confirm Calcite
>> should support it.
>>
>> Simplified example
>>
>> create table test1 (field1 text, field2 text);
>>
>> select field1,field2 from test1 order by field2;    ---- this works fine
>>
>> select field1 from test1 order by field2;   ---- this errors with a message
>> like "org.apache.calcite.sql.validate.SqlValidatorException: Column 'field2'
>> not found in any table"
>>
>> Should this syntax be valid in Calcite?
>>
>> thanks
>>
>>


Re: ORDER BY usage

Posted by Julian Hyde <jh...@apache.org>.
Surprised this doesn't work. It works for me:

$ ./sqlline
sqlline> !connect
jdbc:calcite:model=example/csv/src/test/resources/model.json sa ""
0: jdbc:calcite:model=example/csv/src/test/re> select empno from
sales.emps order by deptno;
+-------+
| EMPNO |
+-------+
| 100   |
| 110   |
| 120   |
| 110   |
| 130   |
+-------+
5 rows selected (0.252 seconds)
0: jdbc:calcite:model=example/csv/src/test/re>

Julian


On Thu, Sep 15, 2016 at 6:02 PM, Homer <lo...@gmail.com> wrote:
> Hi,
>
> I'm having an issue validating a query (using Calcite 1.8)  with an order by
> statement that doesn't reference columns in the select clause.  I'm sure the
> issue is mine in the meta processing but just wanted to confirm Calcite
> should support it.
>
> Simplified example
>
> create table test1 (field1 text, field2 text);
>
> select field1,field2 from test1 order by field2;    ---- this works fine
>
> select field1 from test1 order by field2;   ---- this errors with a message
> like "org.apache.calcite.sql.validate.SqlValidatorException: Column 'field2'
> not found in any table"
>
> Should this syntax be valid in Calcite?
>
> thanks
>
>