You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Sanjiv Kumar <kt...@gmail.com> on 2016/06/13 11:36:03 UTC

Pivot in Apache Drill

Does Apache Drill Supports Sql Pivot.

I have this:-
SQL QUERY for Creating TABLE is:-

`create table Attribute (ID int ,Name varchar(250))`.

INSERT QUERY is:-

`insert into Attribute values(1, 'Description'),
                                      (2, 'StockNumber'),
                                      (3, 'Price'),
                                      (4, 'Logo'),
                                      (5, 'Diagram');`

I want show row data (i.e:- Description, StockNumber, Price, Logo, Diagram)
as column.

I have this sql pivot query:-

`select *
from
(
  select id,name
  from Attribute
) d
pivot
(
max(id)
  for name in ([Description],[StockNumber],[Price],[Logo],[Diagram]
) piv;`


How to convert this sql query in apache drill.?

OR Is There any other solution for that.?


 ......................
  Thanks & Regards

Re: Pivot in Apache Drill

Posted by Jinfeng Ni <ji...@gmail.com>.
Drill currently does not support Sql Pivot. Seems this is not a
functionality defined in SQL standard ISO/SEC9075-2. The SQL planner
that Drill uses, Apache Calcite, also does not have support of this
syntax.

If this is a very commonly used functionality, we may consider adding
support in future.





On Mon, Jun 13, 2016 at 4:36 AM, Sanjiv Kumar <kt...@gmail.com> wrote:
> Does Apache Drill Supports Sql Pivot.
>
> I have this:-
> SQL QUERY for Creating TABLE is:-
>
> `create table Attribute (ID int ,Name varchar(250))`.
>
> INSERT QUERY is:-
>
> `insert into Attribute values(1, 'Description'),
>                                       (2, 'StockNumber'),
>                                       (3, 'Price'),
>                                       (4, 'Logo'),
>                                       (5, 'Diagram');`
>
> I want show row data (i.e:- Description, StockNumber, Price, Logo, Diagram)
> as column.
>
> I have this sql pivot query:-
>
> `select *
> from
> (
>   select id,name
>   from Attribute
> ) d
> pivot
> (
> max(id)
>   for name in ([Description],[StockNumber],[Price],[Logo],[Diagram]
> ) piv;`
>
>
> How to convert this sql query in apache drill.?
>
> OR Is There any other solution for that.?
>
>
>  ......................
>   Thanks & Regards