Skip to content

Commit 9b3bfcb

Browse files
committed
refactor trino json parsing
1 parent e0feb9d commit 9b3bfcb

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

presto/query_json/stage_info.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ type RawPlanWrapper struct {
4949
Plan json.RawMessage `json:"plan"`
5050
}
5151

52-
func selectStats(stats *StageExecutionStats, stageExecutionInfo *StageExecutionInfo) *StageExecutionStats {
53-
if stats != nil {
54-
return stats
55-
}
56-
if stageExecutionInfo != nil {
57-
return stageExecutionInfo.Stats
58-
}
59-
return nil
60-
}
61-
6252
func (s *StageInfo) PrepareForInsert(flattened *[]*StageInfo, queryPlan map[string]RawPlanWrapper) error {
6353
if s == nil {
6454
return nil
@@ -69,7 +59,10 @@ func (s *StageInfo) PrepareForInsert(flattened *[]*StageInfo, queryPlan map[stri
6959
}
7060
// Trino plan does not have a last attempt execution info, unlike Presto
7161
// https://github.com/prestodb/presto/commit/009a234eac113194396d858df69c23a4c578e3f0#diff-d1065b7bf35e2a6b74d251e3d7c2a439e3a029057f87c3a166b89074dd58c4ee
72-
stats := selectStats(s.TrinoStats, s.LatestAttemptExecutionInfo)
62+
stats := s.TrinoStats
63+
if stats == nil && s.LatestAttemptExecutionInfo != nil {
64+
stats = s.LatestAttemptExecutionInfo.Stats
65+
}
7366
stats.GcInfo = new(StageGcInfo)
7467
if err := json.Unmarshal(*stats.GcInfoJson, stats.GcInfo); err != nil {
7568
return err

0 commit comments

Comments
 (0)