-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implemented a new sql
explain analyze graphical
(#16543)
* feat: Add support for `Explain Analyze Graphical` statement in sql * refactor: refactoring graphical by partial method * chore: run lin * refactor: Simplify return of DataBlock vector * chore(test): add json struct validation for the explain analyze graphical result * feat(test): explain analyze graphical * feat(test): rewrite explain analyze graphical test * fix: explain analyze graphical test * fix: remove an extra space from the explain profile result file
- Loading branch information
Showing
11 changed files
with
166 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,7 @@ pub enum Plan { | |
}, | ||
ExplainAnalyze { | ||
partial: bool, | ||
graphical: bool, | ||
plan: Box<Plan>, | ||
}, | ||
|
||
|
4 changes: 4 additions & 0 deletions
4
tests/suites/1_stateful/02_query/02_0009_explain_profile.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
2 | ||
0 | ||
true | ||
0 |
39 changes: 39 additions & 0 deletions
39
tests/suites/1_stateful/02_query/02_0009_explain_profile.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
response=$(curl -s -u root: -XPOST "http://localhost:8000/v1/query" -H 'Content-Type: application/json' -d '{"sql": "explain analyze graphical select 1"}') | ||
|
||
data=$(echo $response | jq -r '.data') | ||
|
||
json_string=$(echo "$data" | jq -r '.[][]') | ||
profiles=$(echo "$json_string" | jq -r '.profiles') | ||
|
||
profile_count=$(echo "$profiles" | jq length) | ||
# Check the number of profiles | ||
echo $profile_count | ||
|
||
# Initialize memory_usage, error_count, cpu_time | ||
memory_usage=0 | ||
error_count=0 | ||
cpu_time=0 | ||
|
||
# Loop through profiles and calculate statistics | ||
for i in $(seq 0 $((profile_count - 1))); do | ||
profile=$(echo "$profiles" | jq ".[$i]") | ||
statistics=$(echo "$profile" | jq '.statistics') | ||
errors=$(echo "$profile" | jq '.errors') | ||
|
||
# Check if statistics has enough data (17 elements) | ||
if [ "$(echo "$statistics" | jq length)" -ge 17 ]; then | ||
memory_usage=$((memory_usage + $(echo "$statistics" | jq '.[16]'))) | ||
cpu_time=$((cpu_time + $(echo "$statistics" | jq '.[0]'))) | ||
fi | ||
|
||
|
||
# Count errors | ||
error_count=$((error_count + $(echo "$errors" | jq length))) | ||
done | ||
|
||
|
||
echo $memory_usage | ||
echo "$( [ "$cpu_time" -gt 0 ] && echo true || echo false )" | ||
echo $error_count | ||
|