M. Justin created CASSANDRA-14391: ------------------------------------- Summary: COPY FROM ignores headers Key: CASSANDRA-14391 URL: https://issues.apache.org/jira/browse/CASSANDRA-14391 Project: Cassandra Issue Type: Bug Components: CQL Environment: cqlsh 5.0.1 and Cassandra 3.11.2 on macOS 10.13.2. Reporter: M. Justin
COPY FROM appears to ignore the headers value, even when "headers = true" is specified. This means that if the columns are reordered, the import process will save values in the wrong columns. h2. Example {noformat:title=temp.csv} col2,col1,col3 column value 1,key2,3 column value 2,key4,3 column value 3,key3,3 column value 4,key1,3 {noformat} {code:sql} create keyspace copy_to_from_test WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; use copy_to_from_test; create table test_table (col1 text primary key, col2 text, col3 bigint); copy test_table from 'temp.csv' with header = true; {code} The above code will incorrectly swap the "col2" and "col1" values, since it expects the first column to be "col1". If I had instead swapped the order of "col3", I would have received an error on input, as it would have attempted to store text in a numerical column. h2. Expected Behavior I would expect specifying "with header = true" on a COPY FROM statement to use the headers as column names for insertion, rather than merely skipping the header row. A question is whether missing columns should be an error, or just not imported. h2. Other I ran across this issue when copying between two of my environments. One of the environments had changed the columns in the primary key, but the other had not yet. This caused the order of the columns to vary between the environments. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org