use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlTimezoneFormatTest method testSimpleDateFormatPST.
@Issue("2904")
@Test
public void testSimpleDateFormatPST() {
String sqlQuery = String.format("SELECT time, date_format(time, 'yyyy-MM-dd HH:mm:ss', 'PST') AS \"f-date\" FROM \"%s\" %n" + "WHERE datetime = '2016-06-03T09:23:00.000Z'", TEST_METRIC_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<String> expectedColumnValues = Collections.singletonList("2016-06-03 02:23:00");
assertTableContainsColumnValues(expectedColumnValues, resultTable, "f-date");
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class CoalesceTest method testCoalesceNumericTypes.
@Test
public void testCoalesceNumericTypes() {
String sqlQuery = "SELECT coalesce(1, 1.0)";
StringTable table = queryTable(sqlQuery);
String actualType = table.getColumnMetaData(0).getDataType();
assertEquals("Wrong COALESCE() function result type", "double", actualType);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlPeriodExtendTest method testPeriodExtendOptionWithMultipleEntityWithStartAndEndDate.
@Issue("3066")
@Test
public void testPeriodExtendOptionWithMultipleEntityWithStartAndEndDate() {
String sqlQuery = String.format("SELECT entity, datetime, AVG(value) FROM \"%s\" %n" + "WHERE datetime >= '2016-07-14T15:00:05.000Z' AND datetime < '2016-07-14T15:00:09.000Z' %n" + "GROUP BY entity, PERIOD(1 SECOND,EXTEND, LINEAR) %nORDER BY datetime", TEST_METRIC_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(// <--interpolated by NEXT
Arrays.asList(TEST_ENTITY1_NAME, "2016-07-14T15:00:05.000Z", "1.0"), // <--interpolated by NEXT
Arrays.asList(TEST_ENTITY2_NAME, "2016-07-14T15:00:05.000Z", "3.0"), Arrays.asList(TEST_ENTITY1_NAME, "2016-07-14T15:00:06.000Z", "1.0"), Arrays.asList(TEST_ENTITY2_NAME, "2016-07-14T15:00:06.000Z", "3.0"), // <--interpolated by LINEAR
Arrays.asList(TEST_ENTITY1_NAME, "2016-07-14T15:00:07.000Z", "1.5"), // <--interpolated by PREVIOUS
Arrays.asList(TEST_ENTITY2_NAME, "2016-07-14T15:00:07.000Z", "3.0"), Arrays.asList(TEST_ENTITY1_NAME, "2016-07-14T15:00:08.000Z", "2.0"), // <--interpolated by PREVIOUS
Arrays.asList(TEST_ENTITY2_NAME, "2016-07-14T15:00:08.000Z", "3.0"));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlPeriodExtendTest method testPeriodExtendOptionWithMultipleEntityWithEndDate.
@Issue("3066")
@Test
public void testPeriodExtendOptionWithMultipleEntityWithEndDate() {
String sqlQuery = String.format("SELECT entity, datetime, AVG(value) FROM \"%s\" %n" + "WHERE tags.a LIKE 'b%%' AND datetime < '2016-07-14T15:00:09.000Z' %n" + "GROUP BY entity, PERIOD(1 SECOND,EXTEND, LINEAR) %nORDER BY datetime", TEST_METRIC_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Arrays.asList(TEST_ENTITY1_NAME, "2016-07-14T15:00:06.000Z", "1.0"), Arrays.asList(TEST_ENTITY2_NAME, "2016-07-14T15:00:06.000Z", "3.0"), // <--interpolated by LINEAR
Arrays.asList(TEST_ENTITY1_NAME, "2016-07-14T15:00:07.000Z", "1.5"), // <--interpolated by PREVIOUS
Arrays.asList(TEST_ENTITY2_NAME, "2016-07-14T15:00:07.000Z", "3.0"), Arrays.asList(TEST_ENTITY1_NAME, "2016-07-14T15:00:08.000Z", "2.0"), // <--interpolated by PREVIOUS
Arrays.asList(TEST_ENTITY2_NAME, "2016-07-14T15:00:08.000Z", "3.0"));
assertTableRowsExist(expectedRows, resultTable);
}
use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.
the class SqlIsNullOperatorTest method testIsNullMetricSpecifiedTag.
@Issue("2937")
@Test
public void testIsNullMetricSpecifiedTag() {
String sqlQuery = String.format("SELECT entity, datetime, value, tags.* %n" + "FROM \"%s\" %n" + "WHERE datetime >= '2016-06-19T11:00:00.000Z' and datetime < '2016-06-19T11:11:00.000Z' %n" + "AND tags.tag4 IS NULL %n", TEST_METRIC_NAME);
StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
List<List<String>> expectedRows = Arrays.asList(Arrays.asList(TEST_ENTITY1_NAME, "2016-06-19T11:00:00.000Z", "1", "val1", "null"), Arrays.asList(TEST_ENTITY2_NAME, "2016-06-19T11:05:00.000Z", "2", "val2", "val2"), Arrays.asList(TEST_ENTITY3_NAME, "2016-06-19T11:10:00.000Z", "3", "null", "val3"));
assertTableRowsExist(expectedRows, resultTable);
}
Aggregations