-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.psql
More file actions
66 lines (51 loc) · 1.37 KB
/
database.psql
File metadata and controls
66 lines (51 loc) · 1.37 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
-- File: database.psql
-- Project: Apache NiFi Timestamp Resolution Blog
--
-- Copyright © Lima Buttgereit Holdings LLC d/b/a Muse Systems
-- This file may include content copyrighted and licensed from third parties.
--
-- See the LICENSE file in the project root for license terms and conditions.
-- See the NOTICE file in the project root for copyright ownership information.
--
-- muse.information@musesystems.com :: https://muse.systems
\set ON_ERROR_STOP true
\c postgres
CREATE DATABASE muse_nifi_example_db;
\c muse_nifi_example_db
CREATE TABLE source_table (
id
bigint
PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY
,test_timestamp
timestamptz
NOT NULL DEFAULT clock_timestamp()
);
CREATE TABLE avro_destination (
id
bigint
PRIMARY KEY
,test_timestamp
timestamptz
NOT NULL DEFAULT clock_timestamp()
);
CREATE TABLE json_destination (
id
bigint
PRIMARY KEY
,test_timestamp
timestamptz
NOT NULL DEFAULT clock_timestamp()
);
DO
$POPULATE$
DECLARE
v_counter integer := 100;
BEGIN
<< source_insert_loop >>
WHILE v_counter > 0 LOOP
INSERT INTO source_table DEFAULT VALUES;
PERFORM pg_sleep(round(random()*100000)/1000000);
v_counter := v_counter - 1;
END LOOP source_insert_loop;
END;
$POPULATE$ LANGUAGE plpgsql;