0
votes
  1. I am not able to get the alias name for the first column
    For example my query is :

    Create External Table '' USING (DELIMETER ',' INCLUDEHEADER REMOTESOURCE 'YES') as
    Select 'ABC' as TABLENAME,
    Count(1) AS Row_Count From ABC;

In this case my output in .csv file is :

,ROW_COUNT
ABC,20000

Here I am not getting the first alias which is 'TABLENAME'

  1. I am not able to get alias name when my select statement contains "COALESCE" function
    For example my query is :

    Create External Table '' USING (DELIMETER ',' INCLUDEHEADER REMOTESOURCE 'YES') as
    Select 'ABC' as TABLENAME,
    Coalesce(Sum(COLUMN1),0) as COLUMN1,
    Sum(COLUMN2) as COLUMN2,
    Coalesce(Sum(COLUMN3),0) as COLUMN3
    From ABC;

In this case my output in .csv file is :

,,COLUMN2,
ABC,2123,4535,5652

Here I am not getting the column name of the first alias and the alias where I have used 'COALESCE' function

1

1 Answers

1
votes

Try wrapping the SELECT part of the query in a simple sub-select. For example:

Create External Table '' USING (DELIMETER ',' INCLUDEHEADER REMOTESOURCE 'YES') as

SELECT * FROM  (          /* this line added */

     Select 'ABC' as TABLENAME,
     Count(1) AS Row_Count From ABC

) SUB1                   /* this line added */