use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlFunctionMathTest method testRound.
@Issue("3049")
@Test
public void testRound() {
String sqlQuery = String.format("SELECT ROUND(value) FROM\"%s\" %nWHERE entity = '%s'", TEST_METRIC_NAME, TEST_ENTITY_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Collections.singletonList(Double.toString(Math.round(2.11))), Collections.singletonList(Double.toString(Math.round(7.567))), Collections.singletonList(Double.toString(Math.round(-1.23))));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlFunctionMathTest method testMod.
@Issue("3049")
@Test
public void testMod() {
String sqlQuery = String.format("SELECT MOD(value,2.11) FROM\"%s\" %nWHERE entity = '%s'", TEST_METRIC_NAME, TEST_ENTITY_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Collections.singletonList(Double.toString(Mod(2.11, 2.11))), Collections.singletonList(Double.toString(Mod(7.567, 2.11))), Collections.singletonList(Double.toString(Mod(-1.23, 2.11))));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlFunctionMathTest method testSqrt.
@Issue("3049")
@Test
public void testSqrt() {
String sqlQuery = String.format("SELECT SQRT(value) FROM\"%s\" %n WHERE entity = '%s'", TEST_METRIC_NAME, TEST_ENTITY_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Collections.singletonList(Double.toString(Math.sqrt(2.11))), Collections.singletonList(Double.toString(Math.sqrt(7.567))), Collections.singletonList("NaN"));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlFunctionMathTest method testExp.
@Issue("3049")
@Test
public void testExp() {
String sqlQuery = String.format("SELECT EXP(value) FROM\"%s\" %nWHERE entity = '%s'", TEST_METRIC_NAME, TEST_ENTITY_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Collections.singletonList(Double.toString(Math.exp(2.11))), Collections.singletonList(Double.toString(Math.exp(7.567))), Collections.singletonList(Double.toString(Math.exp(-1.23))));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlTest method assertSqlQueryRows.
public void assertSqlQueryRows(String message, List<List<String>> expectedRows, String sqlQuery) {
StringTable resultTable = queryTable(sqlQuery);
// See #5057
if (expectedRows.size() > 0) {
for (int timeout = 100; timeout <= 1600 && resultTable.getRows().size() == 0; timeout *= 2) {
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
e.printStackTrace();
}
resultTable = queryTable(sqlQuery);
}
}
assertTableRowsExist(String.format("%s%nWrong result of the following SQL query: %n\t%s", message, sqlQuery), expectedRows, resultTable);
}
Aggregations