|
|
-
Running the HiveQL from the shell prompt.
Techy Teck 2012-08-08, 02:46
This is my below HiveQL query that I am running from the shell prompt. The only confusion that I am having with this is, If you see double quotes before first SELECT in red color, it gets closed on the red color *#. *So should I escape the *# *character or it will be running fine like this also?
hive -e *"*SELECT user_id ,product_id ,prod_and_ts_split FROM ( SELECT * FROM ( SELECT user_id ,prod_and_ts.product_id AS product_id ,prod_and_ts.timestamps AS timestamps FROM testingtable2 LATERAL VIEW explode(purchased_item) exploded_table AS prod_and_ts where user_id is NOT NULL ) prod_and_ts ) tt2 LATERAL VIEW explode(split(timestamps, *"#"*)) exploded_table2 AS prod_and_ts_split WHERE to_date(from_unixtime(cast(prod_and_ts_split AS BIGINT))) '2012-07-12' GROUP BY user_id ,product_id ,prod_and_ts_split ORDER BY user_id ,prod_and_ts_split DESC"
-
Re: Running the HiveQL from the shell prompt.
Jan Dolinár 2012-08-08, 05:01
The shell will interpret the query in your command as SELECT ... explode(split(timestamps, *#*)) ... if you run it the way you wrote it, i.e. without the quotation. The way around this is to either escape the quotation marks or use single quotes:
hive -e *"*SELECT user_id ,product_id ,prod_and_ts_split FROM ( SELECT * FROM ( SELECT user_id ,prod_and_ts.product_id AS product_id ,prod_and_ts.timestamps AS timestamps FROM testingtable2 LATERAL VIEW explode(purchased_item) exploded_table AS prod_and_ts where user_id is NOT NULL ) prod_and_ts ) tt2 LATERAL VIEW explode(split(timestamps, *\**"#\"*)) exploded_table2 AS prod_and_ts_split WHERE to_date(from_unixtime(cast(prod_and_ts_split AS BIGINT))) '2012-07-12' GROUP BY user_id ,product_id ,prod_and_ts_split ORDER BY user_id ,prod_and_ts_split DESC"
or
... explode(split(timestamps, *'**#'*)) ... Best regards, Jan
On Wed, Aug 8, 2012 at 4:46 AM, Techy Teck <[EMAIL PROTECTED]> wrote:
> This is my below HiveQL query that I am running from the shell prompt. The > only confusion that I am having with this is, If you see double quotes > before first SELECT in red color, it gets closed on the red color *#. *So > should I escape the *# *character or it will be running fine like this > also? > > > > hive -e *"*SELECT user_id > ,product_id > ,prod_and_ts_split > FROM ( > SELECT * > FROM ( > SELECT user_id > ,prod_and_ts.product_id AS product_id > ,prod_and_ts.timestamps AS timestamps > FROM testingtable2 LATERAL VIEW explode(purchased_item) exploded_table > AS prod_and_ts where user_id is NOT NULL > ) prod_and_ts > ) tt2 LATERAL VIEW explode(split(timestamps, *"#"*)) exploded_table2 AS > prod_and_ts_split > WHERE to_date(from_unixtime(cast(prod_and_ts_split AS BIGINT))) > '2012-07-12' > GROUP BY user_id > ,product_id > ,prod_and_ts_split > ORDER BY user_id > ,prod_and_ts_split DESC" >
-
Re: Running the HiveQL from the shell prompt.
Raihan Jamal 2012-08-08, 05:47
Thanks Jan for the suggestion.
*Raihan Jamal*
On Tue, Aug 7, 2012 at 10:01 PM, Jan Dolinár <[EMAIL PROTECTED]> wrote:
> The shell will interpret the query in your command as SELECT > ... explode(split(timestamps, *#*)) ... if you run it the way you wrote > it, i.e. without the quotation. The way around this is to either escape the > quotation marks or use single quotes: > > hive -e *"*SELECT user_id > ,product_id > ,prod_and_ts_split > FROM ( > SELECT * > FROM ( > SELECT user_id > ,prod_and_ts.product_id AS product_id > ,prod_and_ts.timestamps AS timestamps > FROM testingtable2 LATERAL VIEW explode(purchased_item) exploded_table AS > prod_and_ts where user_id is NOT NULL > ) prod_and_ts > ) tt2 LATERAL VIEW explode(split(timestamps, *\**"#\"*)) exploded_table2 > AS prod_and_ts_split > WHERE to_date(from_unixtime(cast(prod_and_ts_split AS BIGINT))) > '2012-07-12' > GROUP BY user_id > ,product_id > ,prod_and_ts_split > ORDER BY user_id > ,prod_and_ts_split DESC" > > or > > ... explode(split(timestamps, *'**#'*)) ... > > > Best regards, > Jan > > > On Wed, Aug 8, 2012 at 4:46 AM, Techy Teck <[EMAIL PROTECTED]>wrote: > >> This is my below HiveQL query that I am running from the shell prompt. >> The only confusion that I am having with this is, If you see double quotes >> before first SELECT in red color, it gets closed on the red color *#. *So >> should I escape the *# *character or it will be running fine like this >> also? >> >> >> >> hive -e *"*SELECT user_id >> ,product_id >> ,prod_and_ts_split >> FROM ( >> SELECT * >> FROM ( >> SELECT user_id >> ,prod_and_ts.product_id AS product_id >> ,prod_and_ts.timestamps AS timestamps >> FROM testingtable2 LATERAL VIEW explode(purchased_item) exploded_table >> AS prod_and_ts where user_id is NOT NULL >> ) prod_and_ts >> ) tt2 LATERAL VIEW explode(split(timestamps, *"#"*)) exploded_table2 AS >> prod_and_ts_split >> WHERE to_date(from_unixtime(cast(prod_and_ts_split AS BIGINT))) >> '2012-07-12' >> GROUP BY user_id >> ,product_id >> ,prod_and_ts_split >> ORDER BY user_id >> ,prod_and_ts_split DESC" >> > >
|
|