@Test
public void selectExpressions() throws HBqlException {
final String query1 = "SELECT val1, val5, (val5 - val5 + val5) as val6, (val5+val5) as val7 FROM tab8";
HStatement stmt = connection.createStatement();
HResultSet<HRecord> results1 = stmt.executeQuery(query1);
List<String> testKeyVals = Lists.newArrayList();
List<String> testVal1Vals = Lists.newArrayList();
List<Integer> testVal5Vals = Lists.newArrayList();
List<Integer> testVal6Vals = Lists.newArrayList();
int rec_cnt = 0;
for (HRecord rec : results1) {
String keyval = (String)rec.getCurrentValue("keyval");
String val1 = (String)rec.getCurrentValue("val1");
Integer val5 = (Integer)rec.getCurrentValue("val5");
Integer val6 = (Integer)rec.getCurrentValue("val6");
testKeyVals.add(keyval);
testVal1Vals.add(val1);
testVal5Vals.add(val5);
testVal6Vals.add(val6);
System.out.println("Current Values: " + keyval
+ " - " + rec.getCurrentValue("val1")
+ " - " + rec.getCurrentValue("val5")
+ " - " + rec.getCurrentValue("val6")
);
rec_cnt++;
}
assertTrue(testKeyVals.equals(keyList));
assertTrue(testVal1Vals.equals(val1List));
assertTrue(testVal5Vals.equals(val5List));
assertTrue(testVal6Vals.equals(val5List));
stmt = connection.createStatement();
List<HRecord> recList2 = stmt.executeQueryAndFetch(query1);
assertTrue(recList2.size() == rec_cnt);
final String query3 = "SELECT val1, val5, (val5 - val5 + val5) as val6, (val5+val5) as val7 FROM tab8 " +
"WITH KEYS '0000000001' , '0000000002'";
stmt = connection.createStatement();
List<HRecord> recList3 = stmt.executeQueryAndFetch(query3);
assertTrue(recList3.size() == 2);
final String query4 = "SELECT val1, val5, (val5 - val5 + val5) as val6, (val5+val5) as val7 FROM tab8 " +
"WITH KEYS :key1";