[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-20 Thread lomoree
Github user lomoree closed the pull request at:

https://github.com/apache/phoenix/pull/215


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-12 Thread lomoree
Github user lomoree commented on a diff in the pull request:

https://github.com/apache/phoenix/pull/215#discussion_r83024234
  
--- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java ---
@@ -1120,8 +1120,11 @@ public static SQLException 
unwrapSqlException(SQLException root){
 Exception e = root;
 while(e.getCause() != null){
 e = (Exception) e.getCause();
+if(e instanceof RuntimeException && e.getCause() instanceof 
SQLException) {
--- End diff --

Latest changes attempt to locate the nested SQLException within an 
RuntimeException. We still throw the first SQLException seen in case there's no 
wrapping argument exception. And if no matches are found, we throw the root so 
as to avoid unexpected behavior.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-11 Thread JamesRTaylor
Github user JamesRTaylor commented on a diff in the pull request:

https://github.com/apache/phoenix/pull/215#discussion_r82912355
  
--- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java ---
@@ -1115,4 +1115,15 @@ public static Object convertSqlLiteral(SqlLiteral 
literal, PhoenixRelImplementor
 + " to its object type.", ex);
 }
 }
+
+public static SQLException unwrapSqlException(SQLException root){
+Exception e = root;
+while(e.getCause() != null){
+e = (Exception) e.getCause();
+if(e instanceof SQLException){
+root = (SQLException) e;
+}
+}
+return root;
+}
--- End diff --

Yes, we'd definitely want to catch RuntimeException and look for a nested 
SQLException. I'd stop at the first SQLException we find and throw that one.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-11 Thread maryannxue
Github user maryannxue commented on a diff in the pull request:

https://github.com/apache/phoenix/pull/215#discussion_r82879380
  
--- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java ---
@@ -1115,4 +1115,15 @@ public static Object convertSqlLiteral(SqlLiteral 
literal, PhoenixRelImplementor
 + " to its object type.", ex);
 }
 }
+
+public static SQLException unwrapSqlException(SQLException root){
+Exception e = root;
+while(e.getCause() != null){
+e = (Exception) e.getCause();
+if(e instanceof SQLException){
+root = (SQLException) e;
+}
+}
+return root;
+}
--- End diff --

Thanks for the modification, @lomoree! It think it's fine to go for the 
deepest SQLException. But meanwhile I'm not sure if we should catch 
RuntimeException as well and then either unwrap it if we can find an inner 
SQLException or wrap it if not. @JamesRTaylor Any idea?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-11 Thread lomoree
Github user lomoree commented on a diff in the pull request:

https://github.com/apache/phoenix/pull/215#discussion_r82853555
  
--- Diff: 
phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java 
---
@@ -161,6 +162,29 @@ public Object apply(
 }));
 }
 
+public CalciteStatement createStatement(String sql, int 
resultSetType, int resultSetConcurrency, int resultSetHoldability) throws 
SQLException {
+try {
+return super.createStatement(resultSetType, 
resultSetConcurrency, resultSetHoldability);
+} catch (SQLException e) {
+if (e.getCause().getCause() instanceof SQLException) {
+throw (SQLException) e.getCause().getCause();
--- End diff --

The new changes go for the deepest SQL exception. Can quickly change it if 
you would like only the next most deep SQL exception.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-10 Thread lomoree
Github user lomoree commented on a diff in the pull request:

https://github.com/apache/phoenix/pull/215#discussion_r82688259
  
--- Diff: 
phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java 
---
@@ -161,6 +162,29 @@ public Object apply(
 }));
 }
 
+public CalciteStatement createStatement(String sql, int 
resultSetType, int resultSetConcurrency, int resultSetHoldability) throws 
SQLException {
+try {
+return super.createStatement(resultSetType, 
resultSetConcurrency, resultSetHoldability);
+} catch (SQLException e) {
+if (e.getCause().getCause() instanceof SQLException) {
+throw (SQLException) e.getCause().getCause();
--- End diff --

I wondered about this myself. While I didn't encounter any cases where 
exception levels varied, it's a good idea to account for it. Will make these 
changes, thanks @maryannxue


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-10 Thread maryannxue
Github user maryannxue commented on a diff in the pull request:

https://github.com/apache/phoenix/pull/215#discussion_r82686793
  
--- Diff: 
phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java 
---
@@ -161,6 +162,29 @@ public Object apply(
 }));
 }
 
+public CalciteStatement createStatement(String sql, int 
resultSetType, int resultSetConcurrency, int resultSetHoldability) throws 
SQLException {
+try {
+return super.createStatement(resultSetType, 
resultSetConcurrency, resultSetHoldability);
+} catch (SQLException e) {
+if (e.getCause().getCause() instanceof SQLException) {
+throw (SQLException) e.getCause().getCause();
--- End diff --

Can we can have a utility method that unwraps the Exception? And as we 
might different number of levels of Exception wrapping, can we just look down 
one level at a time till we hit an instance of SQLException?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] phoenix pull request #215: PHOENIX-3345 SQLException code's not propagating ...

2016-10-06 Thread lomoree
GitHub user lomoree opened a pull request:

https://github.com/apache/phoenix/pull/215

PHOENIX-3345 SQLException code's not propagating as expected

-- Primarily impacts unit tests in QueryCompilerTest.java

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/bloomberg/phoenix exceptions

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/phoenix/pull/215.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #215


commit a2c8bdf051773ff83dc6bb94ffcfd1edf2efd13b
Author: ERIC LOMORE 
Date:   2016-10-06T21:01:39Z

PHOENIX-3345 SQLException code's not propogating as expected




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---