#!/bin/bash set -euo pipefail export PGUSER=postgres dropdb parquet || true createdb parquet here=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") psql parquet << EOF CREATE TABLE no_nulls1( rowid INT2, bool_0 INT2, int8_1 INT2, int16_2 INT2, int32_3 INT4, int64_4 INT8, ts_5 int8, double_6 DOUBLE PRECISION, string_7 TEXT, string_8 TEXT, binary_9 TEXT, binary_10 TEXT ); CREATE TABLE no_nulls2 (LIKE no_nulls1); CREATE TABLE nulls (LIKE no_nulls1); COPY no_nulls1 FROM '$here/no-nulls.csv'; COPY no_nulls2 FROM '$here/no-nulls.csv'; COPY nulls FROM '$here/nulls.csv'; CREATE OR REPLACE FUNCTION quote(TEXT) RETURNS TEXT AS \$\$ BEGIN RETURN CASE WHEN \$1 IS NULL THEN 'NULL' ELSE \$1 END; END; \$\$ LANGUAGE 'plpgsql' IMMUTABLE; CREATE OR REPLACE FUNCTION datetime(INT8, TEXT) RETURNS TEXT AS \$\$ BEGIN RETURN to_timestamp(\$1) AT TIME ZONE 'UTC'; END; \$\$ LANGUAGE 'plpgsql' IMMUTABLE; CREATE OR REPLACE FUNCTION printf(TEXT, DOUBLE PRECISION) RETURNS TEXT AS \$\$ BEGIN RETURN CAST(\$2 AS DECIMAL(10, 2))::TEXT; END; \$\$ LANGUAGE 'plpgsql' IMMUTABLE; EOF