Files
impala/www/query_stmt.tmpl
Surya Hebbar 47dd78d838 IMPALA-12688: Support JSON profile imports in webUI
A button has been added to import query profiles on the queries page.

The button opens a system dialog to browse only "*.json" files from
client's local file system. This allows multiple JSON query profiles
to be imported.

JSON profiles are read from file system using FileReader API and then
these imported query profiles are stored in a NoSQL database using
browser's IndexedDB API.

If an error is encountered while parsing JSON profile, it is displayed
on the queries page.

IndexedDB is a large-scale NoSQL database system, that can be read
and written to asynchronously. Hence, the file size and number of JSON
profiles is only limited by the storage available on the client system.

The storage limit is browser dependent, in chromium based browsers
upto 80% of local storage may be used by IndexedDB.

The profile is parsed for the following attributes, which will be
displayed on the queries page. Number of imported queries is also
displayed.

- Query ID
- User
- Default Db
- Query Type
- Start Time
- End Time
- Bytes Read
- Bytes Sent
- Query State
- No. of rows fetched
- Resource Pool
- Query Statement

After importing or deleting query profiles, page will scroll back
to the imported query profiles section.

The queries are sorted based on descending order of the "Start Time".

A button is displayed beside the import button to easily clear all
the imported queries at once.

On opening any of the imported queries, its query timeline will be
displayed. Currently the following tabs are supported for imported
queries.

- Query Statement
- Query Timeline
- Query Text Plan

Syntax highlighting on query statement tab has also been supported.

Change-Id: Ife6eb59bf2030fd19fc92aaf134eb51c609e04d0
Reviewed-on: http://gerrit.cloudera.org:8080/20867
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2024-02-11 12:02:50 +00:00

88 lines
2.9 KiB
Cheetah

{{?__raw__}}{{{profile}}}{{/__raw__}}
{{^__raw__}}
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
{{> www/common-header.tmpl }}
{{> www/query_detail_tabs.tmpl }}
<!-- Enable the 'highlight' library, which does syntax highlighting of query
statements -->
<link rel="stylesheet" href="{{ __common__.host-url }}/www/highlight/styles/default.css">
<script src="{{ __common__.host-url }}/www/highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<span id="tab_body">{{?stmt}}<pre class="code"><code>{{stmt}}</code></pre>{{/stmt}}</span>
<script>
$("#stmt-tab").addClass("active");
var dbOpenReq = indexedDB.open("imported_queries");
var db;
var supported_tabs = ["Query", "Timeline", "Text plan"];
if (window.location.search.includes("imported")) {
var alertMessage = document.getElementsByClassName("alert alert-danger")[0];
if (alertMessage) {
alertMessage.remove();
}
var nav_links = document.getElementsByClassName("nav nav-tabs")[0];
nav_links = nav_links.getElementsByClassName("nav-link");
for (var i = 0; i < nav_links.length;) {
if (supported_tabs.includes(nav_links[i].textContent)) {
nav_links[i].href = `${nav_links[i].href}&imported=true`;
i++;
} else {
nav_links[i].parentElement.remove();
}
}
dbOpenReq.onsuccess = (e) => {
db = e.target.result;
db.onerror = (e) => {
console.log("IndexedDB error");
console.log(e);
}
var profileStore = db.transaction("profiles", "readonly").objectStore("profiles");
var query = {};
query.id = window.location.search;
query.id = query.id.substring(10, query.id.indexOf("&"));
profileStore.get(query.id).onsuccess = (e) => {
query = e.target.result;
var sql_query = query.profile.child_profiles[0].info_strings
.find(({key}) => key === "Sql Statement").value;
var sql_stmt_body = document.createElement("pre");
sql_stmt_body.className = "code";
var sql_code = sql_stmt_body.appendChild(document.createElement("code"))
sql_code.innerHTML = sql_query;
tab_body.innerHTML = "";
tab_body.appendChild(sql_stmt_body);
hljs.highlightBlock(sql_stmt_body);
};
};
}
</script>
{{> www/common-footer.tmpl }}
{{/__raw__}}