You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Manisha Gayathri <ma...@wso2.com> on 2012/08/10 13:03:00 UTC

ORDER BY does not work with CONCAT operation

Hi,

I have a Cassandra Column Family and I need to write some of the data to a
file in the local file system. And the data in the file should be ordered
by the payload_logTime.

Below is the code segment I used to write the data to the file. But still
the data does not get Ordered properly.

INSERT OVERWRITE LOCAL DIRECTORY
home/manisha/Desktop/logDir/logs/0/Application_Server/2012_07_31
select concat(
'Message[',payload_message,']\t',
'Stacktrace ',payload_stacktrace,'\t',
'Logger{',payload_logger,'}\t',
'Priority[',payload_priority,']\t',
(from_unixtime(payload_logTime,'yyyy-MM-dd HH:mm:ss.SSS' )),'\n')  from
LogStats
ORDER BY '_col0';

Appreciate some assistance on this.
Thanks
-- 
~Regards
*Manisha Eleperuma*
Software Engineer
WSO2, Inc.: http://wso2.com
lean.enterprise.middleware

*mobile:  +94 71 8279777*
*
*

Re: ORDER BY does not work with CONCAT operation

Posted by Philip Tromans <ph...@gmail.com>.
I think you're ordering by a constant. Give your concat column an
alias, and then order by that.

Phil.

On 10 August 2012 12:26, Joshi, Rekha <Re...@intuit.com> wrote:
> Manisha, when you say concat issue, did you verify the stmt without concat
> (just any few fields to test) and that gives ordered data correctly?
>
> i.e., below works? (home with /, this time :-) )
> INSERT OVERWRITE LOCAL DIRECTORY
> /home/manisha/Desktop/logDir/logs/0/Application_Server/2012_07_31
> select payload_message ,  payload_logger ,
> from_unixtime(payload_logTime,'yyyy-MM-dd HH:mm:ss.SSS' ))
> from LogStats
> ORDER BY '_col0';
>
> Anyhow try order by logTime instead of order by '_col0' - am not sure what
> this _col0 is referring in your dataset.
>
> Thanks
> Rekha
>
> From: Manisha Gayathri <ma...@wso2.com>
> Reply-To: <us...@hive.apache.org>
> Date: Fri, 10 Aug 2012 16:33:00 +0530
> To: <us...@hive.apache.org>
> Subject: ORDER BY does not work with CONCAT operation
>
> Hi,
>
> I have a Cassandra Column Family and I need to write some of the data to a
> file in the local file system. And the data in the file should be ordered by
> the payload_logTime.
>
> Below is the code segment I used to write the data to the file. But still
> the data does not get Ordered properly.
>
> INSERT OVERWRITE LOCAL DIRECTORY
> home/manisha/Desktop/logDir/logs/0/Application_Server/2012_07_31
> select concat(
> 'Message[',payload_message,']\t',
> 'Stacktrace ',payload_stacktrace,'\t',
> 'Logger{',payload_logger,'}\t',
> 'Priority[',payload_priority,']\t',
> (from_unixtime(payload_logTime,'yyyy-MM-dd HH:mm:ss.SSS' )),'\n')  from
> LogStats
> ORDER BY '_col0';
>
> Appreciate some assistance on this.
> Thanks
> --
> ~Regards
> Manisha Eleperuma
> Software Engineer
> WSO2, Inc.: http://wso2.com
> lean.enterprise.middleware
>
> mobile:  +94 71 8279777
>
>

Re: ORDER BY does not work with CONCAT operation

Posted by "Joshi, Rekha" <Re...@intuit.com>.
Manisha, when you say concat issue, did you verify the stmt without concat (just any few fields to test) and that gives ordered data correctly?

i.e., below works? (home with /, this time :-) )
INSERT OVERWRITE LOCAL DIRECTORY /home/manisha/Desktop/logDir/logs/0/Application_Server/2012_07_31
select payload_message ,  payload_logger ,
from_unixtime(payload_logTime,'yyyy-MM-dd HH:mm:ss.SSS' ))
from LogStats
ORDER BY '_col0';

Anyhow try order by logTime instead of order by '_col0' - am not sure what this _col0 is referring in your dataset.

Thanks
Rekha

From: Manisha Gayathri <ma...@wso2.com>>
Reply-To: <us...@hive.apache.org>>
Date: Fri, 10 Aug 2012 16:33:00 +0530
To: <us...@hive.apache.org>>
Subject: ORDER BY does not work with CONCAT operation

Hi,

I have a Cassandra Column Family and I need to write some of the data to a file in the local file system. And the data in the file should be ordered by the payload_logTime.

Below is the code segment I used to write the data to the file. But still the data does not get Ordered properly.

INSERT OVERWRITE LOCAL DIRECTORY home/manisha/Desktop/logDir/logs/0/Application_Server/2012_07_31
select concat(
'Message[',payload_message,']\t',
'Stacktrace ',payload_stacktrace,'\t',
'Logger{',payload_logger,'}\t',
'Priority[',payload_priority,']\t',
(from_unixtime(payload_logTime,'yyyy-MM-dd HH:mm:ss.SSS' )),'\n')  from LogStats
ORDER BY '_col0';

Appreciate some assistance on this.
Thanks
--
~Regards
Manisha Eleperuma
Software Engineer
WSO2, Inc.: http://wso2.com<http://wso2.com/>
lean.enterprise.middleware

mobile:  +94 71 8279777