timescale / timescaledb-parallel-copy

A binary for parallel copying of CSV data into a TimescaleDB hypertable
https://www.timescale.com/
Apache License 2.0
370 stars 55 forks source link

panic: pq: invalid input syntax for type timestamp: "2021-11-02 00:00:04.130" #52

Open TobiasKrok opened 3 years ago

TobiasKrok commented 3 years ago

Hi,

I'm trying to copy values where the date format is like 2021-11-02 00:00:04.130. The table is of type timestamp(3). I tried inserting it manually and it worked. Any idea why it does not let me insert?

avegao commented 1 year ago

I have the same issue.

I try with

2023-07-20 22:02:38
2023-07-20 22:02:38.000
2023-07-20 22:02:38.000Z
2023-07-20 22:02:38Z
2023-07-20 22:02:38 UTC
2023-07-20 22:02:38.000 UTC
2023-07-20 22:02:38.000 +0
2023-07-20 22:02:38 +0

And always fail.

miladhub commented 1 year ago

I have the same problem:

$ timescaledb-parallel-copy \
  --connection "host=localhost user=ts sslmode=disable" \
  --db-name ts \
  --table stocks_real_time \
  --file ticks-sample.csv \
  --workers 4 \
  --truncate \
  --verbose \
  --log-batches

panic: ERROR: invalid input syntax for type timestamp with time zone: "time" (SQLSTATE 22007)

goroutine 23 [running]:
main.processBatches(0x0, 0x0)
    /Users/skovola/Documents/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy/main.go:261 +0x8b1
created by main.main
    /Users/skovola/Documents/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy/main.go:161 +0x570

Here's my data file, it's just the first few lines from the original file downloaded from https://docs.timescale.com/getting-started/latest/time-series-data/:

$ cat ticks-sample.csv 
time,symbol,price,day_volume
2023-08-02 23:59:59+00,KO,62,
2023-08-02 23:59:59+00,TSLA,255.44,
2023-08-02 23:59:59+00,DIS,86.41,
2023-08-02 23:59:59+00,KO,62,
2023-08-02 23:59:59+00,DIS,86.41,
2023-08-02 23:59:58+00,PYPL,67.95,
2023-08-02 23:59:58+00,AMD,109.79,
2023-08-02 23:59:58+00,BMY,61.84,
2023-08-02 23:59:57+00,DIS,86.38,

The table is taken from the getting started, https://docs.timescale.com/getting-started/latest/tables-hypertables/:

CREATE TABLE stocks_real_time (
  time TIMESTAMPTZ NOT NULL,
  symbol TEXT NOT NULL,
  price DOUBLE PRECISION NULL,
  day_volume INT NULL
);

The \COPY detailed at https://docs.timescale.com/getting-started/latest/time-series-data/ command works using the same file.

I'm using an M1 MacBookPro, this is the version of timescaledb-parallel-copy:

$ timescaledb-parallel-copy -version
timescaledb-parallel-copy 0.4.1-dev (darwin amd64)

My PostgreSQL version is 14.8 (Homebrew) and the TimescaleDB version is 2.11.1.

addypy commented 11 months ago

Worked for me once I added the --skip-header flag