use of org.apache.drill.exec.store.easy.text.reader.HeaderBuilder in project drill by apache.
the class TestHeaderBuilder method testSyntax.
@Test
public void testSyntax() {
Path dummyPath = new Path("file:/dummy.csv");
HeaderBuilder hb = new HeaderBuilder(dummyPath);
parse(hb, "a_123");
validateHeader(hb, new String[] { "a_123" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "a_123_");
validateHeader(hb, new String[] { "a_123_" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "az09_");
validateHeader(hb, new String[] { "az09_" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "+");
validateHeader(hb, new String[] { "column_1" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "+,-");
validateHeader(hb, new String[] { "column_1", "column_2" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "+9a");
validateHeader(hb, new String[] { "col_9a" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "9a");
validateHeader(hb, new String[] { "col_9a" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "a+b");
validateHeader(hb, new String[] { "a_b" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "a_b");
validateHeader(hb, new String[] { "a_b" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "EXPR$0");
validateHeader(hb, new String[] { "EXPR_0" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "(_-^-_)");
validateHeader(hb, new String[] { "col_______" });
}
use of org.apache.drill.exec.store.easy.text.reader.HeaderBuilder in project drill by apache.
the class TestHeaderBuilder method testParser.
private void testParser(String input, String[] expected) {
Path dummyPath = new Path("file:/dummy.csv");
HeaderBuilder hb = new HeaderBuilder(dummyPath);
parse(hb, input);
hb.finishRecord();
validateHeader(hb, expected);
}
use of org.apache.drill.exec.store.easy.text.reader.HeaderBuilder in project drill by apache.
the class TestHeaderBuilder method testWhiteSpace.
@Test
public void testWhiteSpace() {
Path dummyPath = new Path("file:/dummy.csv");
HeaderBuilder hb = new HeaderBuilder(dummyPath);
parse(hb, "a");
validateHeader(hb, new String[] { "a" });
hb = new HeaderBuilder(dummyPath);
parse(hb, " a ");
validateHeader(hb, new String[] { "a" });
hb = new HeaderBuilder(dummyPath);
parse(hb, " a ");
validateHeader(hb, new String[] { "a" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "a,b,c");
validateHeader(hb, new String[] { "a", "b", "c" });
hb = new HeaderBuilder(dummyPath);
parse(hb, " a , b , c ");
validateHeader(hb, new String[] { "a", "b", "c" });
}
use of org.apache.drill.exec.store.easy.text.reader.HeaderBuilder in project drill by apache.
the class TestHeaderBuilder method testEmptyHeader.
@Test
public void testEmptyHeader() {
Path dummyPath = new Path("file:/dummy.csv");
HeaderBuilder hb = new HeaderBuilder(dummyPath);
try {
hb.finishRecord();
} catch (UserException e) {
assertTrue(e.getMessage().contains("must define at least one header"));
}
hb = new HeaderBuilder(dummyPath);
parse(hb, "");
try {
hb.finishRecord();
} catch (UserException e) {
assertTrue(e.getMessage().contains("must define at least one header"));
}
hb = new HeaderBuilder(dummyPath);
parse(hb, " ");
validateHeader(hb, new String[] { "column_1" });
hb = new HeaderBuilder(dummyPath);
parse(hb, ",");
validateHeader(hb, new String[] { "column_1", "column_2" });
hb = new HeaderBuilder(dummyPath);
parse(hb, " , ");
validateHeader(hb, new String[] { "column_1", "column_2" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "a, ");
validateHeader(hb, new String[] { "a", "column_2" });
}
use of org.apache.drill.exec.store.easy.text.reader.HeaderBuilder in project drill by apache.
the class TestHeaderBuilder method testUnicode.
@Test
public void testUnicode() {
Path dummyPath = new Path("file:/dummy.csv");
HeaderBuilder hb = new HeaderBuilder(dummyPath);
parse(hb, "Αθήνα");
validateHeader(hb, new String[] { "Αθήνα" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "Москва");
validateHeader(hb, new String[] { "Москва" });
hb = new HeaderBuilder(dummyPath);
parse(hb, "Paris,Αθήνα,Москва");
validateHeader(hb, new String[] { "Paris", "Αθήνα", "Москва" });
}
Aggregations