From 5d1af7d884ae26660695de7363f6bbce053b66d8 Mon Sep 17 00:00:00 2001 From: xvrl Date: Sat, 2 Mar 2013 14:09:20 -0800 Subject: [PATCH] support aliasing --- .../main/antlr4/com/metamx/druid/sql/antlr4/DruidSQL.g4 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/main/antlr4/com/metamx/druid/sql/antlr4/DruidSQL.g4 b/client/src/main/antlr4/com/metamx/druid/sql/antlr4/DruidSQL.g4 index 458c4c7b2c0..47096aebffb 100644 --- a/client/src/main/antlr4/com/metamx/druid/sql/antlr4/DruidSQL.g4 +++ b/client/src/main/antlr4/com/metamx/druid/sql/antlr4/DruidSQL.g4 @@ -148,7 +148,13 @@ datasource ; aliasedExpression returns [PostAggregator p] - : expression ( AS^ name=IDENT )? { $p = $expression.p; } + : expression ( AS^ name=IDENT )? { + if($name != null) { + postAggregators.add($expression.p); + $p = new FieldAccessPostAggregator($name.text, $expression.p.getName()); + } + else $p = $expression.p; + } ; expression returns [PostAggregator p]