public class CopyFromCommandExecutor extends AbstractCopyCommandExecutor
COPY <tableName>[(<columns>)] FROM <origin>[ WITH <options>[ AND <options> ...]]: where tableName
is the name of the table into which the rows are inserted (it may be prefixed with the keyspace name), *
columns is a subset of columns to import from the CSV file specified by adding a comma-separated list of
column names, origin is a string literal (with single quotes) representing the path to the imported file;
and options are the options among the following:
BATCHSIZE: the number of rows inserted in a single batch.
Defaults to .DECIMALSEP: the character that is used as the decimal point separator.
Defaults to .DELIMITER: the character that is used to separate fields.
Defaults to .ESCAPE: the character that is used to escape the literal uses of the QUOTE character.
Defaults to .HEADER: whether the first line in the CSV input file will contain the column names.
Defaults to false.MAXROWS: the maximum number of rows to import, negative meaning unlimited.
Defaults to .NULLVAL: the string placeholder for null values. Defaults to .QUOTE: the character that is used to enclose field values.
Defaults to .SKIPCOLS: a comma-separated list of column names to ignore.
By default, no columns are skipped.SKIPROWS: the number of initial rows to skip. Defaults to .THOUSANDSSEP: the character that is used to separate thousands.
Defaults to the empty string.
If the path to the imported file is not absolute, it is interpreted relative to the current working directory.
The tilde shorthand notation ('~/dir') is supported for referring to the home directory.
The format to define the value of an option is: <optionName> = <value>. The value must be quoted if it
is a string literal.
The following options are not supported:
BOOLSTYLECHUNKSIZECONFIGFILEDATETIMEFORMATERRFILEINGESTRATEMAXATTEMPTSMAXBATCHSIZE (use BATCHSIZE instead)MAXINSERTERRORSMAXPARSEERRORSMINBATCHSIZE (use BATCHSIZE instead)NULL (use NULLVAL instead)NUMPROCESSESRATEFILEREPORTFREQUENCYTTLSQLSyntaxErrorException.
A successful command execution will return a result set with a single row containing some information about the
import process in a column result.
The documentation of the original COPY FROM command is available:
| Constructor and Description |
|---|
CopyFromCommandExecutor(String tableName,
String columns,
String origin,
Properties options)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
com.datastax.oss.driver.api.core.cql.ResultSet |
execute(CassandraStatement statement,
String cql)
Executes the given CQL statement as a special command not handled by the Java driver.
|
public CopyFromCommandExecutor(@Nonnull String tableName, String columns, @Nonnull String origin, @Nonnull Properties options) throws SQLSyntaxErrorException
tableName - The parameter tableName of the command.columns - The optional parameter columns of the command.origin - The parameter origin of the command.options - The optional parameter options of the command already parsed into a Properties
instance.SQLSyntaxErrorException - if an unknown option is used.public com.datastax.oss.driver.api.core.cql.ResultSet execute(CassandraStatement statement, String cql) throws SQLException
statement - The Cassandra statement.cql - The CQL statement to execute.SpecialCommandsUtil.buildEmptyResultSet()) if the command is not expected to return some results.SQLException - if something went wrong with the Cassandra statement.Copyright © 2020–2026 ING Bank. All rights reserved.