Я пытаюсь использовать pgloader для загрузки текстового файла (формат копирования, сгенерированный из pgdump) в таблицу.
В целевой таблице есть 2 столбца, для которых я не хочу предоставлять данные:
- и
id
столбец типа integer
, не ноль, со значением по умолчанию из nextval('identifier_reference_id_seq'::regclass)
- столбец
tagged_by
, который равен character varying
и может иметь значение null
Для столбца id я просто хочу, чтобы база данных присвоила идентификатор. Что касается строкового столбца, я просто не беспокоюсь об этом и не хочу его заполнять.
Может ли pgloader загружать данные в этом сценарии, или вам нужно предоставить идентификатор, а также значение для всех столбцов?
версия pgloader:
$ pgloader --version
pgloader version "3.6.1"
compiled with SBCL 1.5.8
posgre sql версия: 9.6
Мой файл загрузки pgloader (load-identifer-table.load):
LOAD COPY
FROM copy:///tmp/data_to_copy.sql
(
created, updated, geo_id, reference_id
)
INTO postgresql://{{POSTGRES_USER}}:{{POSTGRES_PASSWORD}}@localhost:5432/{{POSTGRES_DB}}
TARGET TABLE identifier_reference
SET work_mem to '256MB'
;
Команда, которую я запускаю: pgloader -D ./ -L load.log scripts/load-identifer-table.load
Ниже приведен вывод, который я получаю:
pgloader -D ./ -L load.log scripts/load-channel-tags.load
2020-03-06T19:24:27.015000Z LOG pgloader version "3.6.1"
2020-03-06T19:24:27.024000Z LOG Data errors in '/tmp/'
2020-03-06T19:24:27.024000Z LOG Parsing commands from file #P"/tmp/load-identifer-table.load"
; in: LAMBDA (PGLOADER.SOURCES::ROW)
; (VECTOR PGLOADER.USER-SYMBOLS::CREATED PGLOADER.USER-SYMBOLS::UPDATED
; PGLOADER.USER-SYMBOLS::ID PGLOADER.USER-SYMBOLS::GEO_ID
; PGLOADER.USER-SYMBOLS::REFERENCE_ID PGLOADER.USER-SYMBOLS::TAGGED_BY)
; --> MAKE-ARRAY MAKE-ARRAY LOCALLY
; ==>
; (VECTOR PGLOADER.USER-SYMBOLS::CREATED PGLOADER.USER-SYMBOLS::UPDATED
; PGLOADER.USER-SYMBOLS::ID PGLOADER.USER-SYMBOLS::GEO_ID
; PGLOADER.USER-SYMBOLS::REFERENCE_ID PGLOADER.USER-SYMBOLS::TAGGED_BY)
;
; caught WARNING:
; undefined variable: PGLOADER.USER-SYMBOLS::ID
;
; caught WARNING:
; undefined variable: PGLOADER.USER-SYMBOLS::TAGGED_BY
;
; compilation unit finished
; Undefined variables:
; PGLOADER.USER-SYMBOLS::ID PGLOADER.USER-SYMBOLS::TAGGED_BY
; caught 2 WARNING conditions
2020-03-06T19:24:27.398000Z WARNING Target table "\"public\".\"identifier_reference\"" has 2 indexes defined against it.
2020-03-06T19:24:27.398000Z WARNING That could impact loading performance badly.
2020-03-06T19:24:27.398000Z WARNING Consider the option 'drop indexes'.
2020-03-06T19:24:27.446000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.447000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.448000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.449000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.450000Z ERROR Could not read input: The variable PGLOADER.USER-SYMBOLS::ID is unbound.
2020-03-06T19:24:27.468000Z LOG report summary reset
table name errors rows bytes total time
----------------------- --------- --------- --------- --------------
fetch 0 0 0.008s
----------------------- --------- --------- --------- --------------
"public"."channel_tag" 24 0 0.066s
----------------------- --------- --------- --------- --------------
Files Processed 0 1 0.023s
COPY Threads Completion 0 2 0.102s
----------------------- --------- --------- --------- --------------
Total import time 24 0 0.125s
Схема таблицы: С psql:
Table "public.identifier_reference"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+-----------------------------------------
created | timestamp with time zone | | |
updated | timestamp with time zone | | |
id | integer | | not null | nextval('identifier_reference_id_seq'::regclass)
geo_id | character varying | | not null |
reference_id | integer | | not null |
tagged_by | character varying | | |
Indexes:
"identifier_reference_pkey" PRIMARY KEY, btree (id)
"identifier_reference_ids_unique_cons" UNIQUE CONSTRAINT, btree (string_identifier, reference_id)
Foreign-key constraints:
"identifier_reference_geo_id_fkey" FOREIGN KEY (geo_id) REFERENCES geo(id)
"identifier_reference_reference_id_fkey" FOREIGN KEY (reference_id) REFERENCES reference(id)