@Test public void testTextTable() throws Exception {
String sql = "SELECT * from texttable(file columns x string WIDTH 1, y date width 10 skip 10) as x"; //$NON-NLS-1$
Query query = new Query();
query.setSelect(new Select(Arrays.asList(new AllSymbol())));
TextTable tt = new TextTable();
tt.setFile(new ElementSymbol("file"));
List<TextTable.TextColumn> columns = new ArrayList<TextTable.TextColumn>();
columns.add(new TextTable.TextColumn("x", "string", 1));
columns.add(new TextTable.TextColumn("y", "date", 10));
tt.setColumns(columns);
tt.setSkip(10);
tt.setName("x");
query.setFrom(new From(Arrays.asList(tt)));
helpTest(sql, "SELECT * FROM TEXTTABLE(file COLUMNS x string WIDTH 1, y date WIDTH 10 SKIP 10) AS x", query);
sql = "SELECT * from texttable(file columns x string, y date delimiter ',' escape '\"' header skip 10) as x"; //$NON-NLS-1$
tt.setDelimiter(',');
tt.setQuote('"');
tt.setEscape(true);
tt.setHeader(1);
for (TextColumn textColumn : columns) {
textColumn.setWidth(null);
}
helpTest(sql, "SELECT * FROM TEXTTABLE(file COLUMNS x string, y date DELIMITER ',' ESCAPE '\"' HEADER SKIP 10) AS x", query);
}