asfgit closed pull request #1578: DRILL-6913: Fix multiple error output in the
console
URL: https://github.com/apache/drill/pull/1578
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
index 7a4fcdf5b07..c7963a50abe 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
@@ -62,6 +62,34 @@ public static PhysicalPlan getPlan(QueryContext context,
String sql) throws Fore
return getPlan(context, sql, null);
}
+ /**
+ * Converts sql query string into query physical plan.
+ * Catches various exceptions and converts them into user exception when
possible.
+ *
+ * @param context query context
+ * @param sql sql query
+ * @param textPlan text plan
+ * @return query physical plan
+ */
+ public static PhysicalPlan getPlan(QueryContext context, String sql,
Pointer<String> textPlan) throws ForemanSetupException {
+ try {
+ return convertPlan(context, sql, textPlan);
+ } catch (ValidationException e) {
+ String errorMessage = e.getCause() != null ? e.getCause().getMessage() :
e.getMessage();
+ throw UserException.validationError(e)
+ .message(errorMessage)
+ .build(logger);
+ } catch (AccessControlException e) {
+ throw UserException.permissionError(e)
+ .build(logger);
+ } catch (SqlUnsupportedException e) {
+ throw UserException.unsupportedError(e)
+ .build(logger);
+ } catch (IOException | RelConversionException e) {
+ throw new QueryInputException("Failure handling SQL.", e);
+ }
+ }
+
/**
* Converts sql query string into query physical plan.
* In case of any errors (that might occur due to missing function
implementation),
@@ -75,7 +103,8 @@ public static PhysicalPlan getPlan(QueryContext context,
String sql) throws Fore
* @param textPlan text plan
* @return query physical plan
*/
- public static PhysicalPlan getPlan(QueryContext context, String sql,
Pointer<String> textPlan) throws ForemanSetupException {
+ private static PhysicalPlan convertPlan(QueryContext context, String sql,
Pointer<String> textPlan)
+ throws ForemanSetupException, RelConversionException, IOException,
ValidationException {
Pointer<String> textPlanCopy = textPlan == null ? null : new
Pointer<>(textPlan.value);
try {
return getQueryPlan(context, sql, textPlan);
@@ -102,47 +131,46 @@ public static PhysicalPlan getPlan(QueryContext context,
String sql, Pointer<Str
* @return query physical plan
*/
private static PhysicalPlan getQueryPlan(QueryContext context, String sql,
Pointer<String> textPlan)
- throws ForemanSetupException {
+ throws ForemanSetupException, RelConversionException, IOException,
ValidationException {
final SqlConverter parser = new SqlConverter(context);
-
injector.injectChecked(context.getExecutionControls(), "sql-parsing",
ForemanSetupException.class);
final SqlNode sqlNode = parser.parse(sql);
final AbstractSqlHandler handler;
final SqlHandlerConfig config = new SqlHandlerConfig(context, parser);
switch(sqlNode.getKind()) {
- case EXPLAIN:
- handler = new ExplainHandler(config, textPlan);
- break;
- case SET_OPTION:
- handler = new SetOptionHandler(context);
- break;
- case DESCRIBE_TABLE:
- if (sqlNode instanceof DrillSqlDescribeTable) {
- handler = new DescribeTableHandler(config);
+ case EXPLAIN:
+ handler = new ExplainHandler(config, textPlan);
break;
- }
- case DESCRIBE_SCHEMA:
- if (sqlNode instanceof SqlDescribeSchema) {
- handler = new DescribeSchemaHandler(config);
+ case SET_OPTION:
+ handler = new SetOptionHandler(context);
break;
- }
- case CREATE_TABLE:
- handler = ((DrillSqlCall) sqlNode).getSqlHandler(config, textPlan);
- break;
- case DROP_TABLE:
- case CREATE_VIEW:
- case DROP_VIEW:
- case OTHER_DDL:
- case OTHER:
- if (sqlNode instanceof DrillSqlCall) {
- handler = ((DrillSqlCall) sqlNode).getSqlHandler(config);
+ case DESCRIBE_TABLE:
+ if (sqlNode instanceof DrillSqlDescribeTable) {
+ handler = new DescribeTableHandler(config);
+ break;
+ }
+ case DESCRIBE_SCHEMA:
+ if (sqlNode instanceof SqlDescribeSchema) {
+ handler = new DescribeSchemaHandler(config);
+ break;
+ }
+ case CREATE_TABLE:
+ handler = ((DrillSqlCall) sqlNode).getSqlHandler(config, textPlan);
break;
- }
- // fallthrough
- default:
- handler = new DefaultSqlHandler(config, textPlan);
+ case DROP_TABLE:
+ case CREATE_VIEW:
+ case DROP_VIEW:
+ case OTHER_DDL:
+ case OTHER:
+ if (sqlNode instanceof DrillSqlCall) {
+ handler = ((DrillSqlCall) sqlNode).getSqlHandler(config);
+ break;
+ }
+ // fallthrough
+ default:
+ handler = new DefaultSqlHandler(config, textPlan);
}
boolean returnResultSet =
context.getOptions().getBoolean(ExecConstants.RETURN_RESULT_SET_FOR_DDL);
@@ -151,21 +179,6 @@ private static PhysicalPlan getQueryPlan(QueryContext
context, String sql, Point
context.getOptions().setLocalOption(ExecConstants.RETURN_RESULT_SET_FOR_DDL,
returnResultSet || !SqlKind.DDL.contains(sqlNode.getKind()));
- try {
- return handler.getPlan(sqlNode);
- } catch(ValidationException e) {
- String errorMessage = e.getCause() != null ? e.getCause().getMessage() :
e.getMessage();
- throw UserException.validationError(e)
- .message(errorMessage)
- .build(logger);
- } catch (AccessControlException e) {
- throw UserException.permissionError(e)
- .build(logger);
- } catch(SqlUnsupportedException e) {
- throw UserException.unsupportedError(e)
- .build(logger);
- } catch (IOException | RelConversionException e) {
- throw new QueryInputException("Failure handling SQL.", e);
- }
+ return handler.getPlan(sqlNode);
}
}
diff --git a/pom.xml b/pom.xml
index 01ca3e37820..1d9b29bbb3b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
<guava.version>19.0</guava.version>
<forkCount>2</forkCount>
<parquet.version>1.10.0</parquet.version>
- <calcite.version>1.17.0-drill-r1</calcite.version>
+ <calcite.version>1.17.0-drill-r2</calcite.version>
<avatica.version>1.12.0</avatica.version>
<janino.version>3.0.11</janino.version>
<sqlline.version>1.6.0</sqlline.version>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services