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

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

arina-ielchiieva commented on a change in pull request #1266: DRILL-6423: 
Export query result as a CSV file
URL: https://github.com/apache/drill/pull/1266#discussion_r189245434
 
 

 ##########
 File path: exec/java-exec/src/main/resources/rest/query/result.ftl
 ##########
 @@ -59,11 +75,67 @@
       $('#result').dataTable( {
         "aaSorting": [],
         "scrollX" : true,
+        "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
+        "lengthChange": true,
         "dom": '<"H"lCfr>t<"F"ip>',
         "jQueryUI" : true
       } );
     } );
-  </script>
+
+    //Pop out profile (needed to avoid losing query results)
+    function popOutProfile(queryId) {
+      var profileUrl = location.protocol+'//'+ 
location.host+'/profiles/'+queryId;
+      var tgtWindow = '_blank';
+      window.open(profileUrl, tgtWindow);
+    }
+
+//Ref: https://jsfiddle.net/gengns/j1jm2tjx/
+function download_csv(csvRecords, filename) {
+    var csvFile;
+    var downloadElem;
+
+    //CSV File
+    csvFile = new Blob([csvRecords], {type: "text/csv"});
+    // Download link
+    downloadElem = document.createElement("a");
+    // File name
+    downloadElem.download = filename;
+
+    // We have to create a link to the file
+    downloadElem.href = window.URL.createObjectURL(csvFile);
+
+    // Make sure that the link is not displayed
+    downloadElem.style.display = "none";
+
+    // Add the link to your DOM
+    document.body.appendChild(downloadElem);
+
+    // Launch the download prompt
+    downloadElem.click();
+}
+
+function exportTableAsCsv(queryId) {
+    var filename = queryId+'.csv';
 
 Review comment:
   space after `queryId`.

----------------------------------------------------------------
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:
us...@infra.apache.org


> Export query result as a CSV file
> ---------------------------------
>
>                 Key: DRILL-6423
>                 URL: https://issues.apache.org/jira/browse/DRILL-6423
>             Project: Apache Drill
>          Issue Type: New Feature
>          Components: Web Server
>            Reporter: Kunal Khatua
>            Assignee: Kunal Khatua
>            Priority: Major
>             Fix For: 1.14.0
>
>
> This feature request is based on a question posted in the user mailing list:
> [is there any way to download the data through Drill Web 
> UI?|https://lists.apache.org/thread.html/bd6b2453c83d818b618ec6334891309f42556d4a7de34d84024a43cd@<user.drill.apache.org>]
> Since the results of the WebUI allows for sorting and filtering as well, it 
> can be very useful if there is a way for a user to download the results of an 
> executed query for further processing in other tools (like Excel)



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

Reply via email to