drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Pernsteiner (JIRA)" <j...@apache.org>
Subject [jira] [Created] (DRILL-3435) Some reserved-keywords require table aliasing
Date Tue, 30 Jun 2015 22:45:04 GMT
Andy Pernsteiner created DRILL-3435:

             Summary: Some reserved-keywords require table aliasing
                 Key: DRILL-3435
                 URL: https://issues.apache.org/jira/browse/DRILL-3435
             Project: Apache Drill
          Issue Type: Bug
          Components: Documentation
    Affects Versions: 1.0.0
            Reporter: Andy Pernsteiner
            Assignee: Bridget Bevens
            Priority: Minor

Not only does drill have a number of reserved keywords that require backticking (``), there
also appear to be some reserved words that require extra care, using table aliases to be able
to perform queries.   One that we've found so far is 'user' .  EG, consider the following

/usr/bin/sqlline -u jdbc:drill: -n root


select user from `profiles/2aa32e9e-bdae-8949-8461-c14dafe63ee0.sys.drill` ;
| user  |
| root  |

But the actual file in question has the 'user' as a different user:

cat 2aa32e9e-bdae-8949-8461-c14dafe63ee0.sys.drill|egrep -o 'user\":\"[a-z]+\"'


The workaround  is to alias the table (t) and prefix the 'user' column in the resultset w/
the table alias :

0: jdbc:drill:> select t.`user` from `profiles/2aa32e9e-bdae-8949-8461-c14dafe63ee0.sys.drill`
t ;
|  user   |
| apernsteiner  |

@jinfeng gave the following explanation on the user@ list:

'user' is a SQL reserved word.

When it's used alone, it is a system function, just like CURRENT_USER.  See
http://calcite.incubator.apache.org/docs/reference.html  (System functions

When 'user' is qualified with a table alias, it becomes a column


The drill documentation @ https://drill.apache.org/docs/reserved-keywords/ merely says to
use backticks (``), not to do any table aliasing.  For those who have columns named 'user',
this may be misleading...

This message was sent by Atlassian JIRA

View raw message