COPY cassandra table from csv file

后端 未结 2 1977
花落未央
花落未央 2021-02-15 11:46

I\'m setting up a demo landscape for Cassandra, Apache Spark and Flume on my Mac (Mac OS X Yosemite with Oracle jdk1.7.0_55). The landscape shall work as a proof of concept for

2条回答
  •  梦谈多话
    2021-02-15 12:45

    cqlsh's COPY command can be touchy. However, in the COPY documentation is this line:

    The number of columns in the CSV input is the same as the number of columns in the Cassandra table metadata.

    Keeping that in-mind, I did manage to get your data to import with a COPY FROM, by naming the empty fields (processstarttimeuuid and processendtimeuuid, respectively):

    aploetz@cqlsh:stackoverflow> COPY process (processuuid, processid, processnumber, 
    processname, processstarttime, processstarttimeuuid, processendtime, 
    processendtimeuuid, processstatus, orderer, vorgangsnummer, vehicleid, fin, reference, 
    referencetype) FROM 'Process_BulkData.csv' WITH DELIMITER = ';' AND HEADER = TRUE;
    
    1 rows imported in 0.018 seconds.
    aploetz@cqlsh:stackoverflow> SELECT * FROM process ;
    
     processuuid                          | fin               | orderer | processendtime            | processendtimeuuid | processid         | processname        | processnumber | processstarttime          | processstarttimeuuid | processstatus | reference  | referencetype | vehicleid | vorgangsnummer
    --------------------------------------+-------------------+---------+---------------------------+--------------------+-------------------+--------------------+---------------+---------------------------+----------------------+---------------+------------+---------------+-----------+----------------
     0f0d1498-d149-4fcc-87c9-f12783fdf769 | WAU2345CX67890876 |    SIXT | 2011-02-16 22:05:00+-0600 |               null | AbmeldungKl‰rfall | Abmeldung Kl‰rfall |             1 | 2011-02-02 22:05:00+-0600 |                 null |      Finished | KLA-BR4278 |      internal |    A-XA 1 |           4278
    
    (1 rows)
    

提交回复
热议问题