sonatype-lift[bot] commented on a change in pull request #453:
URL: https://github.com/apache/solr/pull/453#discussion_r766896087



##########
File path: solr/core/src/java/org/apache/solr/handler/SQLHandler.java
##########
@@ -145,17 +150,56 @@ public String getSource() {
     private boolean firstTuple = true;
     List<String> metadataFields = new ArrayList<>();
     Map<String, String> metadataAliases = new HashMap<>();
+    private final boolean returnSolrQueryOnly;
+    private final String sqlQuery;
+    TupleStream queryTupleStream;
 
     SqlHandlerStream(String connectionUrl, String sqlQuery, StreamComparator 
definedSort,
                      Properties connectionProperties, String driverClassName, 
boolean includeMetadata)
         throws IOException {
       super(connectionUrl, sqlQuery, definedSort, connectionProperties, 
driverClassName);
 
       this.includeMetadata = includeMetadata;
+      this.returnSolrQueryOnly = 
"true".equals(connectionProperties.getProperty("returnSolrQueryOnly"));
+      this.sqlQuery = sqlQuery;
+    }
+
+    @Override
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public void open() throws IOException {
+      if (returnSolrQueryOnly) {
+        // Get the Calcite connection and then call prepareSql so we can grab 
the TupleStream directly
+        // to by-pass all the ResultSet creation in the JDBC layer as we just 
want the Solr query for this SQL vs. executing the SQL
+        CalciteConnection calciteConn = (CalciteConnection)openConnection();
+        CalcitePrepare.Context context = calciteConn.createPrepareContext();
+        CalcitePrepare.CalciteSignature sig =
+            (new CalcitePrepareImpl()).prepareSql(context, 
CalcitePrepare.Query.of(sqlQuery), Object[].class, -1);

Review comment:
       I've recorded this as ignored for this pull request. If you change your 
mind, just comment `@sonatype-lift unignore`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to