summaryrefslogtreecommitdiff
path: root/graphs/sql/corrupted_friends
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/sql/corrupted_friends
add: graphs et rushs
Diffstat (limited to 'graphs/sql/corrupted_friends')
-rw-r--r--graphs/sql/corrupted_friends/req01.sql18
-rw-r--r--graphs/sql/corrupted_friends/req02.sql41
-rw-r--r--graphs/sql/corrupted_friends/req03.sql2
3 files changed, 61 insertions, 0 deletions
diff --git a/graphs/sql/corrupted_friends/req01.sql b/graphs/sql/corrupted_friends/req01.sql
new file mode 100644
index 0000000..bc759f7
--- /dev/null
+++ b/graphs/sql/corrupted_friends/req01.sql
@@ -0,0 +1,18 @@
+CREATE TYPE public.prefix AS ENUM (
+ 'MRS',
+ 'MS',
+ 'MR',
+ 'DR'
+);
+
+CREATE TABLE dtf.madelines_contacts
+(
+ id INTEGER PRIMARY KEY,
+ title public.prefix,
+ first_name TEXT,
+ last_name TEXT,
+ phone TEXT,
+ email TEXT,
+ favorite BOOLEAN,
+ created_at TIMESTAMP
+);
diff --git a/graphs/sql/corrupted_friends/req02.sql b/graphs/sql/corrupted_friends/req02.sql
new file mode 100644
index 0000000..11f9947
--- /dev/null
+++ b/graphs/sql/corrupted_friends/req02.sql
@@ -0,0 +1,41 @@
+INSERT INTO dtf.madelines_contacts
+SELECT
+id,
+upper(split_part(regexp_replace(trim(full_name), '([^[[:ascii:]]]*)|([[:digit:]]*)', '', 'g'), ' ', 1))::public.prefix AS title,
+initcap(split_part(regexp_replace(trim(full_name), '([^[[:ascii:]]]*)|([[:digit:]]*)', '', 'g'), ' ', 2)) AS first_name,
+initcap(split_part(regexp_replace(trim(full_name), '([^[[:ascii:]]]*)|([[:digit:]]*)', '', 'g'), ' ', 3)) AS last_name,
+concat(
+ lpad(
+ regexp_replace(
+ regexp_replace(phone, '[^0-9\.\-]', '', 'g'),
+ '(.?.?.?)[\.\-].*',
+ '\1',
+ 'g'
+ ),
+ 3, '0'
+ ),
+ '.',
+ lpad(
+ regexp_replace(
+ regexp_replace(phone, '[^0-9\.\-]', '', 'g'),
+ '.*[\.\-](.?.?.?)[\.\-].*',
+ '\1',
+ 'g'
+ ),
+ 3, '0'
+ ),
+ '.',
+ lpad(
+ regexp_replace(
+ regexp_replace(phone, '[^0-9\.\-]', '', 'g'),
+ '.*[\.\-](.?.?.?)',
+ '\1',
+ 'g'
+ ),
+ 3, '0'
+ )
+) AS phone,
+regexp_replace(trim(email), '[^[[:ascii:]]]', '', 'g') AS email,
+trim(favorite) LIKE '1' AS favorite,
+created_at::timestamp AS created_at
+FROM dtf.madelines_contacts_corrupted AS c
diff --git a/graphs/sql/corrupted_friends/req03.sql b/graphs/sql/corrupted_friends/req03.sql
new file mode 100644
index 0000000..baa5863
--- /dev/null
+++ b/graphs/sql/corrupted_friends/req03.sql
@@ -0,0 +1,2 @@
+UPDATE dtf.madelines_contacts
+SET email = concat(lower(first_name), '.', lower(last_name),'@roger_roger.com');