use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlExampleComputedColumnsTest method testExample1.
@Issue("3073")
@Test(description = "Test for alias documentation example. " + "https://github.com/axibase/atsd-docs/blob/master/api/sql/examples/select-computed-columns.md")
public void testExample1() {
String sqlQuery = String.format("SELECT t1.datetime, t1.entity AS \"entity\", t1.value, t2.value, t1.value + t2.value AS total_cpu %n" + "FROM \"%s\" t1 %nJOIN \"%s\" t2 %n" + "WHERE t1.datetime >= '2016-08-15T07:24:00.000Z' AND t1.datetime < '2016-08-15T07:26:00.000Z' %n" + "AND t2.datetime >= '2016-08-15T07:24:00.000Z' AND t2.datetime < '2016-08-15T07:26:00.000Z' %n", TEST_METRIC1_NAME, TEST_METRIC2_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Arrays.asList("2016-08-15T07:24:46.000Z", TEST_ENTITY_NAME, "4.3", "10.1", "14.399999999999999"), Arrays.asList("2016-08-15T07:25:02.000Z", TEST_ENTITY_NAME, "5.4", "12.2", "17.6"));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlExampleComputedColumnsTest method testExample4.
@Issue("3073")
@Test
public void testExample4() {
String sqlQuery = String.format("SELECT entity, min(value), max(value), max(value) - min(value) %n" + "FROM \"%s\" %n" + "WHERE datetime >= '2016-08-15T07:24:00.000Z' AND datetime < '2016-08-15T07:26:00.000Z' %n" + "GROUP BY entity %nHAVING max(value) - min(value) > 1 %nORDER BY max(value) - min(value) DESC", TEST_METRIC1_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Collections.singletonList(Arrays.asList(TEST_ENTITY_NAME, "4.3", "5.4", "1.1000000000000005"));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlSelectFromAtsdSeriesTest method testExample3.
@Issue("3177")
@Test
public void testExample3() {
String sqlQuery = String.format("SELECT entity, metric, datetime, value %nFROM atsd_series %nWHERE metric = '%s' OR metric = '%s' ORDER BY METRIC %n", TEST_METRIC1_NAME, TEST_METRIC2_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Arrays.asList(TEST_ENTITY_NAME, TEST_METRIC1_NAME, "2016-06-17T19:16:01.000Z", "1.0"), Arrays.asList(TEST_ENTITY_NAME, TEST_METRIC1_NAME, "2016-06-17T19:16:02.000Z", "2.0"), Arrays.asList(TEST_ENTITY_NAME, TEST_METRIC2_NAME, "2016-06-17T19:16:03.000Z", "3.0"), Arrays.asList(TEST_ENTITY_NAME, TEST_METRIC2_NAME, "2016-06-17T19:16:04.000Z", "4.0"));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlFunctionDateFormatWithMaxMinValueTimeTest method testMinValueTime.
@Issue("3184")
@Test
public void testMinValueTime() {
String sqlQuery = String.format("SELECT date_format(MIN_VALUE_TIME(value),'yyyy') FROM \"%s\"", TEST_METRIC_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Collections.singletonList(Collections.singletonList("2016"));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlFunctionMathTest method testPower.
@Issue("3049")
@Test
public void testPower() {
String sqlQuery = String.format("SELECT Power(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(Math.pow(2.11, 2.11))), Collections.singletonList(Double.toString(Math.pow(7.567, 2.11))), Collections.singletonList(Double.toString(Math.pow(-1.23, 2.11))));
assertTableRowsExist(expectedRows, resultTable);
}
Aggregations