Search in sources :

Example 91 with StringTable

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");
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 92 with StringTable

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);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 93 with StringTable

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);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) ArrayList(java.util.ArrayList) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 94 with StringTable

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);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) ArrayList(java.util.ArrayList) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 95 with StringTable

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);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Aggregations

StringTable (com.axibase.tsd.api.model.sql.StringTable)277 Test (org.testng.annotations.Test)276 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)275 Issue (io.qameta.allure.Issue)270 List (java.util.List)147 Response (javax.ws.rs.core.Response)49 ArrayList (java.util.ArrayList)23 Series (com.axibase.tsd.api.model.series.Series)4 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 BeforeTest (org.testng.annotations.BeforeTest)1