File size: 3,069 Bytes
02edc38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
{
  "qid": "049",
  "task_type": "ambig",
  "has_intended_resolution": true,
  "language": "SQLite",
  "db": "github_repos",
  "question": "List the active PR contributors in 2022.",
  "gold_ambiguity_points": [
    {
      "id": "A",
      "phrase": "active",
      "type": "infinite",
      "ambiguity_type": "semantic_value",
      "parameter_name": "pr_count_threshold",
      "parameter_dtype": "int",
      "parameter_sample_operators": [
        ">",
        ">="
      ],
      "parameter_sample_values": [
        100
      ],
      "intended_parameter_operator": ">=",
      "intended_parameter_value": 100
    },
    {
      "id": "B",
      "phrase": "PR",
      "type": "finite",
      "ambiguity_type": "semantic_computation",
      "interpretations": [
        "pull requests submitted",
        "pull requests submitted that were merged"
      ],
      "intended_interpretation_idx": 1
    }
  ],
  "gold_intended_query_id": "GQRY-B.1",
  "extra_info": {}
}
*/


----- START OF GOLD QUERY `GQRY-B.0` -----
/*
{
  "id": "GQRY-B.0",
  "parameter_names": [
    "pr_count_threshold"
  ],
  "parameter_values": {
    "pr_count_threshold": 100
  },
  "other_exec_results": [],
  "required_columns": [
    0
  ],
  "required_sorted": false,
  "extra_info": {
    "ambiguity_resolution": {
      "[A] PR": "pull requests submitted",
      "[B] active": ":pr_count_threshold"
    }
  }
}
*/
SELECT
json_extract(payload, '$.pull_request.user.id') AS contributor,
COUNT(DISTINCT json_extract(payload, '$.pull_request.id')) AS pr_count
FROM YEAR_2022
WHERE type = 'PullRequestEvent'
AND json_extract(payload, '$.action') = 'opened'
GROUP BY contributor
HAVING pr_count >= :pr_count_threshold
ORDER BY pr_count;
/* EXEC RESULT
 contributor  pr_count
    45622341       117
    41898282       120
     6948709       145
    49699333       183
    84948785       324
... TRUNCATED ...
    30538765       355
    30536864       370
    87541280       823
    97608502      1331
      694745      1607
*/
----- END OF GOLD QUERY -----


----- START OF GOLD QUERY `GQRY-B.1` -----
/*
{
  "id": "GQRY-B.1",
  "parameter_names": [
    "pr_count_threshold"
  ],
  "parameter_values": {
    "pr_count_threshold": 100
  },
  "other_exec_results": [],
  "required_columns": [
    0
  ],
  "required_sorted": false,
  "extra_info": {
    "ambiguity_resolution": {
      "[A] PR": "pull requests submitted that were merged",
      "[B] active": ":pr_count_threshold"
    }
  }
}
*/
SELECT
json_extract(payload, '$.pull_request.user.id') AS contributor,
COUNT(DISTINCT json_extract(payload, '$.pull_request.id')) AS pr_count
FROM YEAR_2022
WHERE type = 'PullRequestEvent'
AND json_extract(payload, '$.action') = 'closed'
AND json_extract(payload, '$.pull_request.merged') = true
AND strftime('%Y', json_extract(payload, '$.pull_request.created_at')) = '2022'
GROUP BY contributor
HAVING pr_count >= :pr_count_threshold
ORDER BY pr_count;
/* EXEC RESULT
 contributor  pr_count
    87541280       688
    97608502       880
      694745       997
*/
----- END OF GOLD QUERY -----