-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanImages.sql
More file actions
49 lines (48 loc) · 1.09 KB
/
cleanImages.sql
File metadata and controls
49 lines (48 loc) · 1.09 KB
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
CREATE TABLE relative_path_questions AS
with relative_path_questions as (
SELECT
number,
exam,
regexp_replace(
text,
'https?://[^/\s'']+/[^\s'']+/([^\s'']+\.[^\s'']+)',
'

',
'g'
) as text
from questions
)
select * from relative_path_questions;
CREATE TABLE relative_path_answers AS
with relative_path_answers as (
SELECT
number,
question_number,
question_exam,
regexp_replace(
text,
'https?://[^/\s'']+/[^\s'']+/([^\s'']+\.[^\s'']+)',
'

',
'g'
) as text,
is_correct
from answers
),
clean_dirty_relative_path_answers as (
SELECT
number,
question_number,
question_exam,
CASE
WHEN text LIKE '%pngMost%' THEN
REPLACE(REPLACE(text, 'pngMost', 'png'), 'Voted', '')
ELSE
text
END AS text,
is_correct
from relative_path_answers
)
select * from clean_dirty_relative_path_answers;