This is an automated email from the ASF dual-hosted git repository. parthc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/drill.git
commit 494d828f06ddda9c8091920cf56731bbd00abab0 Author: Kunal Khatua <[email protected]> AuthorDate: Tue May 29 11:20:56 2018 -0700 DRILL-6450: Visualized plans for profiles querying JDBC sources is broken When viewing a profile for a query against a JDBC source, the visualized plan is not rendered. This is because the generated SQL pushed down to the JDBC source has a line break injected just before the FROM clause. The workaround is to strip away any injected newlines ('\\n') at least for the SQL defined in the text plan, so that the backend Javascript can render it correctly. In addition, any single line comments are also removed, but any block comments (i.e. /* .. */ ) are retained as they might carry hints. This closes #1295 --- .../java/org/apache/drill/exec/store/jdbc/JdbcPrel.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcPrel.java b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcPrel.java index abeca23..ac6f31c 100644 --- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcPrel.java +++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcPrel.java @@ -44,7 +44,6 @@ import org.apache.drill.exec.store.jdbc.JdbcStoragePlugin.DrillJdbcConvention; * Represents a JDBC Plan once the children nodes have been rewritten into SQL. */ public class JdbcPrel extends AbstractRelNode implements Prel { - private final String sql; private final double rows; private final DrillJdbcConvention convention; @@ -66,6 +65,18 @@ public class JdbcPrel extends AbstractRelNode implements Prel { rowType = input.getRowType(); } + //Substitute newline. Also stripping away single line comments. Expecting hints to be nested in '/* <hint> */' + private String stripToOneLineSql(String sql) { + StringBuilder strippedSqlTextBldr = new StringBuilder(sql.length()); + String sqlToken[] = sql.split("\\n"); + for (String sqlTextLine : sqlToken) { + if (!sqlTextLine.trim().startsWith("--")) { //Skip comments + strippedSqlTextBldr.append(sqlTextLine).append(' '); + } + } + return strippedSqlTextBldr.toString(); + } + private class SubsetRemover extends RelShuttleImpl { @Override @@ -87,7 +98,7 @@ public class JdbcPrel extends AbstractRelNode implements Prel { @Override public RelWriter explainTerms(RelWriter pw) { - return super.explainTerms(pw).item("sql", sql); + return super.explainTerms(pw).item("sql", stripToOneLineSql(sql)); } @Override -- To stop receiving notification emails like this one, please contact [email protected].
