ydb-platform / ydb

YDB is an open source Distributed SQL Database that combines high availability and scalability with strong consistency and ACID transactions
https://ydb.tech
Apache License 2.0
4.02k stars 588 forks source link

CSV isn't get imported with sync indexes #1565

Open max-arnold opened 9 months ago

max-arnold commented 9 months ago

YDB CLI 2.8.0, Serverless YDB

CREATE TABLE users (
    id String NOT NULL,
    email Utf8 NOT NULL,
    INDEX idx_email GLOBAL SYNC ON (email),
    PRIMARY KEY (id)
);
id|email
12345|user@example.com
ydb --endpoint ydb.serverless.yandexcloud.net:2135 --database /ru-central1/xx/yy --sa-key-file yc-service-account-key.json yql -f tables.sql
ydb --endpoint ydb.serverless.yandexcloud.net:2135 --database /ru-central1/xx/yy --sa-key-file yc-service-account-key.json import file csv -p users --header --delimiter="|" --null-value "" --input-file users.csv
ydb --endpoint ydb.serverless.yandexcloud.net:2135 --database /ru-central1/xx/yy --sa-key-file yc-service-account-key.json yql -s 'select * from users'
┌───────┬────┐
│ email │ id │
├───────┼────┤
└───────┴────┘

The import works if the index is async.

max-arnold commented 9 months ago

Was told in the TG chat that the BulkUpsert method doesn't work with sync indexes. Two suggestions then:

  1. Print some error message in the CLI import command (right now it finishes just fine, but no data gets imported)
  2. Add a documentation note