hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Furcy Pin <furcy....@flaminem.com>
Subject Alias vs Assignment
Date Thu, 08 Oct 2015 12:48:43 GMT
Hi folks,


I would like to start a discussion with the Hive user and developper
community about an element of syntax present in SQL Server that could be
nice to have in Hive.


Back in 2012, before I started Hive, and was using SQL Server, I came
accross this post :

http://sqlblog.com/blogs/aaron_bertrand/archive/2012/01/23/bad-habits-to-kick-using-as-instead-of-for-column-aliases.aspx

that convinced me to write my queries like

#1
SELECT
    myColumn = someFunction(someColumn),
    myOtherColumn = someOtherFunction(someOtherColumn)
FROM ...

rather than

#2
SELECT
    someFunction(someColumn) as myColumn
    someOtherFunction(someOtherColumn) as myOtherColumn
FROM ...

The two syntax are equivalent in SQL Server, but only the second is allowed
in Hive.

In my opinion, there are two advantages of using #1 over #2 (and it seems
the blog post I mention above only mentions the first) :

   1. Readability: usually the name of the columns you are computing
   matters more than how you compute them.
   2. Updates: #1 can easily be transformed into an update query, #2
   requires some rewriting (thank god I discovered Sublime Text and its
   multi-line editing)


On the other side, #1 is unfortunately not ISO compliant, even though IMHO
ISO did not pick the best choice this time... Besides Hive it would not be
Hive's first deviation from ISO.

I would like to hear what do you people think, would it be a good idea to
implement this in Hive?

Cheers,

Furcy

Mime
View raw message