How to setup Greenplum database and table

This readme describes how to setup Greenplum database and table(s).

Pre-requisites:

Run the docker instances:

You can run spark and GPDB instances by using existing scripts.

$./runDocker.sh -t usecase1 -c up

Verify the docker instance is running:

Make sure the docker instances are running by running docker ps

$ docker ps

How to run the setupDB:

This setupDB.sh script automatically creates default database and table(s). The script is located under <src>/data/scripts/setupDB.sh.

1. Connect to the GPDB docker image The Greenplum DB cluster will be running with this instance name: gpdbsne with two segments. To access this docker instance, exec into a container:

$ docker exec -it gpdbsne bin/bash
  1. Execute the command below to access the scripts folder under “/code/data”
[root@d632f535db87]# cd /code/data
  1. Run scripts/setupDB.sh, in order to create a database and table.
[root@d632f535db87 data]# scripts/setupDB.sh
psql:./sample_table.sql:1: NOTICE:  table "basictable" does not exist, skipping
DROP TABLE
psql:./sample_table.sql:5: NOTICE:  CREATE TABLE will create implicit sequence "basictable_id_seq" for serial column "basictable.id"
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 9
INSERT 0 18
INSERT 0 36
INSERT 0 72
INSERT 0 144
INSERT 0 288
INSERT 0 576
INSERT 0 1152
INSERT 0 2304
INSERT 0 4608
  1. Run the following psql command to verify database (basic_db) and table (basictable) are created correctly.
[root@d632f535db87 data]# psql -h localhost -U gpadmin -d basic_db -c "\dt"
           List of relations
 Schema |    Name    | Type  |  Owner
--------+------------+-------+---------
 public | basictable | table | gpadmin
(1 row)
[root@d632f535db87 data]# psql -h localhost -U gpadmin -d basic_db -c "select count(*) from basictable"
 count
-------
  9216
(1 row)