2

In my shell script I am using this query to get the last_value of the column id.

last_val=`beeline -e "select nvl(max(id),0) from testing.1_test"`

The result is

+----------+--+
|   _c0    |
+----------+--+
| 3380901  |
+----------+--+

Now I want to pass this value as variable ${last_val}

when I do echo ${last_val} I want to have 3380901 but I am receiving

+----------+--+
|   _c0    |
+----------+--+
| 3380901  |
+----------+--+

How can I echo 3380901.

When I used hive option like below I got what I want

last_val=`hive -e "select nvl(max(id),0) from testing.1_test"`

echo ${last_val} gave me 3380901

Please let me know how can I do this?

  • 1
    What is the output of `beeline --showHeader=false --outputformat=csv2 -e "select nvl(max(id),0) from testing.1_test"`? – Mirek Długosz Apr 14 '17 at 22:55
  • @MirosławZalewski ` +----------+--+ | 3380901 | +----------+--+` is the output but I want `3380901` –  Apr 14 '17 at 23:02

1 Answers1

0
last_val=`beeline --showHeader=false --outputformat=tsv2 -e "select nvl(max(id),0) from testing.1_test"`
David דודו Markovitz
  • 42,900
  • 6
  • 64
  • 88