lens-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amareshw...@apache.org
Subject lens git commit: LENS-1343 : Fix expression not being propagated to error message in COULD_NOT_PARSE_EXPRESSION error
Date Thu, 06 Oct 2016 04:51:46 GMT
Repository: lens
Updated Branches:
  refs/heads/master e6a59b739 -> 1bb189b30


LENS-1343 : Fix expression not being propagated to error message in COULD_NOT_PARSE_EXPRESSION
error


Project: http://git-wip-us.apache.org/repos/asf/lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/1bb189b3
Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/1bb189b3
Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/1bb189b3

Branch: refs/heads/master
Commit: 1bb189b30f99413fffd5ee978b7fbd728a03c268
Parents: e6a59b7
Author: Rajat Khandelwal <prongs@apache.org>
Authored: Thu Oct 6 10:21:12 2016 +0530
Committer: Amareshwari Sriramadasu <amareshwari@apache.org>
Committed: Thu Oct 6 10:21:12 2016 +0530

----------------------------------------------------------------------
 .../org/apache/lens/cube/parse/HQLParser.java   |  2 +-
 .../apache/lens/cube/parse/TestHQLParser.java   | 21 ++++++++++++++++++++
 lens-cube/src/test/resources/hive-site.xml      | 10 ++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lens/blob/1bb189b3/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java b/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
index 6e52d32..1976248 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/parse/HQLParser.java
@@ -201,7 +201,7 @@ public final class HQLParser {
     try {
       tree = driver.parseExpression(expr);
     } catch (ParseException e) {
-      throw new LensException(COULD_NOT_PARSE_EXPRESSION.getLensErrorInfo(), e, e.getMessage());
+      throw new LensException(COULD_NOT_PARSE_EXPRESSION.getLensErrorInfo(), e, expr);
     }
     return ParseUtils.findRootNonNullToken(tree);
   }

http://git-wip-us.apache.org/repos/asf/lens/blob/1bb189b3/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
index 861d4f7..2619cb0 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/parse/TestHQLParser.java
@@ -25,6 +25,7 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.lens.cube.error.LensCubeErrorCode;
 import org.apache.lens.server.api.error.LensException;
 
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -489,4 +490,24 @@ public class TestHQLParser {
     ASTNode tree = HQLParser.parseHQL(expr, conf);
     Assert.assertEquals(HQLParser.getString((ASTNode) tree.getChild(1).getChild(0)), dirString);
   }
+
+  @DataProvider
+  public Object[][] exprDataProvider() {
+    return new Object[][] {
+      {"a.b", true},
+      {"a.date", false},
+    };
+  }
+
+  @Test(dataProvider = "exprDataProvider")
+  public void testParseExpr(String expr, boolean success) {
+    try {
+      HQLParser.parseExpr(expr);
+      Assert.assertTrue(success);
+    } catch (LensException e) {
+      Assert.assertFalse(success);
+      Assert.assertTrue(e.getMessage().contains(expr));
+      Assert.assertTrue(e.getMessage().contains(LensCubeErrorCode.COULD_NOT_PARSE_EXPRESSION.name()));
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/lens/blob/1bb189b3/lens-cube/src/test/resources/hive-site.xml
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/resources/hive-site.xml b/lens-cube/src/test/resources/hive-site.xml
index d21e61c..68dedfc 100644
--- a/lens-cube/src/test/resources/hive-site.xml
+++ b/lens-cube/src/test/resources/hive-site.xml
@@ -57,4 +57,14 @@
     <value>true</value>
   </property>
 
+  <property>
+    <name>hive.metastore.schema.verification</name>
+    <value>false</value>
+  </property>
+
+  <property>
+    <name>hive.support.sql11.reserved.keywords</name>
+    <value>false</value>
+  </property>
+
 </configuration>


Mime
View raw message