[ 
https://issues.apache.org/jira/browse/DRILL-6450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16498870#comment-16498870
 ] 

ASF GitHub Bot commented on DRILL-6450:
---------------------------------------

parthchandra closed pull request #1295: DRILL-6450: Visualized plans for 
profiles querying JDBC sources is broken
URL: https://github.com/apache/drill/pull/1295
 
 
   

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/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 abeca2302d..ac6f31c4e7 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 @@
  * 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 JdbcPrel(RelOptCluster cluster, RelTraitSet traitSet, 
JdbcIntermediatePre
     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 PhysicalOperator 
getPhysicalOperator(PhysicalPlanCreator creator) throws
 
   @Override
   public RelWriter explainTerms(RelWriter pw) {
-    return super.explainTerms(pw).item("sql", sql);
+    return super.explainTerms(pw).item("sql", stripToOneLineSql(sql));
   }
 
   @Override


 

----------------------------------------------------------------
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]


> Visualized plans for profiles querying JDBC sources is broken
> -------------------------------------------------------------
>
>                 Key: DRILL-6450
>                 URL: https://issues.apache.org/jira/browse/DRILL-6450
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning &amp; Optimization, Storage - JDBC
>    Affects Versions: 1.13.0
>            Reporter: Kunal Khatua
>            Assignee: Kunal Khatua
>            Priority: Major
>              Labels: ready-to-commit
>             Fix For: 1.14.0
>
>
> 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 at least for the SQL 
> defined in the text plan, so that the backend Javascript can render it 
> correctly.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to