public class CsvDBLoader extends DBLoader
DBLoader
which gets its Tables by reading CSV files
using the CsvLoader
class and is the loader use for CSV junit tests.
CsvDBLoader
requires that the CSV files have a specific format
as defined:
list_of_csv_files : (csv_file)+ csv_file: table_definitions table_definitions: (table_definition)+ table_definition: actions table_name column_names column_types (file_name or nos_of_rows or rows) actions: (action)* action: '##' (ActionBefore: | ActionAfter:) action_type action_type: DropIndex index_name | CreateIndex index_name column_name table_name: '##' TableName: table_name column_names: '##' ColumnNames: column_name (',' column_name)* column_types: '##' ColumnTypes: column_types ('.' column_types)* file_name:'##' FileName: relative_filename ? nos_of_rows:'##' NosOfRows: number column_types: type (':' null) type: "INTEGER" "DECIMAL(*,*)" "SMALLINT" "VARCHAR(*)" "REAL" "BOOLEAN" "BIGINT" "DATE" "TIMESTAMP" rows: (row)* row: value (',' value)* if FileName is given, then there is no NosOfRows the file can only contains rows else if NosOfRows is given, then there is no FileName the number of rows in current file are rows for table else the all remaining rows in current file are rows for table fi comment lines start with '#'
See the testsrc/main/mondrian/rolap/aggmatcher/BUG_1541077.csv file for an example.
Modifier and Type | Class and Description |
---|---|
static class |
CsvDBLoader.CsvLoaderRowStream |
static class |
CsvDBLoader.ListRowStream |
DBLoader.Column, DBLoader.Row, DBLoader.RowDefault, DBLoader.RowStream, DBLoader.Table, DBLoader.Type
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_AFTER_TAG |
static String |
ACTION_BEFORE_TAG |
static String |
COLUMN_NAMES_TAG |
static String |
COLUMN_TYPES_TAG |
static String |
CREATE_INDEX_TAG |
static String |
DROP_INDEX_TAG |
static String |
FILE_NAME_TAG |
static String |
NOS_OF_ROWS_TAG |
static String |
TABLE_NAME_TAG |
BATCH_SIZE_PROP, CREATE_TABLE_INDEX_PROP, CREATE_TABLE_INDEX_SUFFIX_DEFAULT, CREATE_TABLE_PROP, CREATE_TABLE_SUFFIX_DEFAULT, dateFormatString, dateFormatter, decimalDataTypeRegex, DROP_TABLE_INDEX_PROP, DROP_TABLE_INDEX_SUFFIX_DEFAULT, DROP_TABLE_PROP, DROP_TABLE_ROWS_PROP, DROP_TABLE_ROWS_SUFFIX_DEFAULT, DROP_TABLE_SUFFIX_DEFAULT, EMPTY_ROW_STREAM, FORCE_PROP, integerFormatter, JDBC_DRIVER_PROP, JDBC_PASSWORD_PROP, JDBC_URL_PROP, JDBC_USER_PROP, LOAD_TABLE_ROWS_PROP, LOAD_TABLE_ROWS_SUFFIX_DEFAULT, LOGGER, nl, oracleDateFormatString, OUTPUT_DIRECTORY_PROP, varcharDataTypeRegex
Constructor and Description |
---|
CsvDBLoader() |
Modifier and Type | Method and Description |
---|---|
protected void |
check() |
protected static File |
checkDirectory(String dirName) |
File |
getInputDirectory() |
String |
getInputDirectoryRegex() |
File |
getInputFile() |
File[] |
getInputFiles() |
DBLoader.Table[] |
getTables() |
DBLoader.Table[] |
getTables(File[] files) |
DBLoader.Table[] |
getTables(Reader reader) |
DBLoader.Table[] |
getTablesFromDirectory() |
DBLoader.Table[] |
getTablesFromFile() |
DBLoader.Table[] |
getTablesFromFiles() |
protected DBLoader.Column[] |
loadColumns(String[] columnNames,
String[] columnTypes,
int lineNos) |
void |
loadTables(File file,
List<DBLoader.Table> tableList) |
void |
loadTables(Reader reader,
List<DBLoader.Table> tableList) |
static void |
main(String[] args) |
void |
setInputDirectory(File inputDirectory) |
void |
setInputDirectoryRegex(String inputDirectoryRegex) |
void |
setInputFile(File inputFile) |
void |
setInputFiles(File[] inputFiles) |
protected static void |
usage(String msg) |
clear, close, closeFileWriter, columnValue, createInsertStatement, decimalFormat, decimalFormat, dropTable, dropTables, embedQuotes, executeAfterActions, executeBeforeActions, executeCreateTable, executeDDL, executeDropTable, executeDropTableRows, executeLoadTableRows, executeStatements, executeStatements, generateAfterActions, generateBeforeActions, generateCreateTable, generateDropTable, generateDropTableRows, generateStatements, generateStatements, getBatchSize, getConnection, getForce, getJdbcDriver, getJdbcURL, getOutputDirectory, getPassword, getUserName, initialize, initializeColumns, makeFileWriter, quoteId, setBatchSize, setConnection, setForce, setJdbcDriver, setJdbcURL, setOutputDirectory, setPassword, setUserName, writeBatch, writeDDL
public static final String ACTION_BEFORE_TAG
public static final String ACTION_AFTER_TAG
public static final String DROP_INDEX_TAG
public static final String CREATE_INDEX_TAG
public static final String TABLE_NAME_TAG
public static final String COLUMN_NAMES_TAG
public static final String COLUMN_TYPES_TAG
public static final String FILE_NAME_TAG
public static final String NOS_OF_ROWS_TAG
public void setInputDirectory(File inputDirectory)
public File getInputDirectory()
public void setInputDirectoryRegex(String inputDirectoryRegex)
public String getInputDirectoryRegex()
public void setInputFiles(File[] inputFiles)
public File[] getInputFiles()
public void setInputFile(File inputFile)
public File getInputFile()
public DBLoader.Table[] getTables() throws Exception
public DBLoader.Table[] getTablesFromDirectory() throws Exception
Exception
public DBLoader.Table[] getTablesFromFiles() throws Exception
Exception
public DBLoader.Table[] getTablesFromFile() throws Exception
Exception
public DBLoader.Table[] getTables(File[] files) throws Exception
Exception
public DBLoader.Table[] getTables(Reader reader) throws Exception
Exception
public void loadTables(File file, List<DBLoader.Table> tableList) throws Exception
Exception
public void loadTables(Reader reader, List<DBLoader.Table> tableList) throws Exception
Exception
protected DBLoader.Column[] loadColumns(String[] columnNames, String[] columnTypes, int lineNos) throws Exception
Exception
protected static File checkDirectory(String dirName) throws Exception
Exception
protected static void usage(String msg)