@Override public long getStartTime() { return session.getStartTime(); }
@Test public void testCurrentTimestamp() { double current = TEST_SESSION.getStartTime() / 1000.0; assertOptimizedEquals("current_timestamp = from_unixtime(" + current + ")", "true"); double future = current + TimeUnit.MINUTES.toSeconds(1); assertOptimizedEquals("current_timestamp > from_unixtime(" + future + ")", "false"); }
@Test public void testCurrentDate() { // current date is the time at midnight in the session time zone assertFunction("CURRENT_DATE", DateType.DATE, new SqlDate(toIntExact(epochDaysInZone(TIME_ZONE_KEY, session.getStartTime())))); }
@Test public void testFunctionWithSessionCall() throws Exception { assertExecute("now()", TIMESTAMP_WITH_TIME_ZONE, new SqlTimestampWithTimeZone(TEST_SESSION.getStartTime(), TEST_SESSION.getTimeZoneKey())); assertExecute("current_timestamp", TIMESTAMP_WITH_TIME_ZONE, new SqlTimestampWithTimeZone(TEST_SESSION.getStartTime(), TEST_SESSION.getTimeZoneKey())); Futures.allAsList(futures).get(); }
private static void assertEqualSessionsWithoutTransactionId(Session actual, Session expected) { assertEquals(actual.getQueryId(), expected.getQueryId()); assertEquals(actual.getIdentity(), expected.getIdentity()); assertEquals(actual.getSource(), expected.getSource()); assertEquals(actual.getCatalog(), expected.getCatalog()); assertEquals(actual.getSchema(), expected.getSchema()); assertEquals(actual.getTimeZoneKey(), expected.getTimeZoneKey()); assertEquals(actual.getLocale(), expected.getLocale()); assertEquals(actual.getRemoteUserAddress(), expected.getRemoteUserAddress()); assertEquals(actual.getUserAgent(), expected.getUserAgent()); assertEquals(actual.getStartTime(), expected.getStartTime()); assertEquals(actual.getSystemProperties(), expected.getSystemProperties()); assertEquals(actual.getConnectorProperties(), expected.getConnectorProperties()); } }
.setUserAgent(session.getUserAgent().orElse(null)) .setClientInfo(session.getClientInfo().orElse(null)) .setStartTime(session.getStartTime()) .build();
getSession().getClientCapabilities(), getSession().getResourceEstimates(), getSession().getStartTime(), ImmutableMap.<String, String>builder() .put("test_string", "foo string")
defaultSession.getClientCapabilities(), defaultSession.getResourceEstimates(), defaultSession.getStartTime(), defaultSession.getSystemProperties(), defaultSession.getConnectorProperties(),
SessionReadResults sessionResults = results.await(); for (Session session : sessionReadResult.getSessions()) { List<DataSet> dataSets = sessionReadResult.getDataSet(session); for (DataSet dataSet : dataSets) { for (DataPoint dataPoint : dataSet.getDataPoints()) { // Create new IndividualSession object, add data to it then add it to arraylist IndividualSession individualSessionObject = new IndividualSession(); individualSessionObject.setFromDate(new Date(session.getStartTime(TimeUnit.SECONDS))); individualSessionObject.setToDate(new Date(session.getEndTime(TimeUnit.SECONDS))); individualSessionObject.setStepCount(dataPoint.getValue(Field.FIELD_STEPS).asInt()); //use the results } } }
@Test public void testCurrentTimestamp() throws Exception { double current = TEST_SESSION.getStartTime() / 1000.0; assertOptimizedEquals("current_timestamp = from_unixtime(" + current + ")", "true"); double future = current + TimeUnit.MINUTES.toSeconds(1); assertOptimizedEquals("current_timestamp > from_unixtime(" + future + ")", "false"); }
@Test public void testLocalTimestamp() { functionAssertions.assertFunction("localtimestamp", TimestampType.TIMESTAMP, toTimestamp(session.getStartTime())); }
@Test public void testFunctionWithSessionCall() throws Exception { assertExecute("now()", TIMESTAMP_WITH_TIME_ZONE, new SqlTimestampWithTimeZone(TEST_SESSION.getStartTime(), TEST_SESSION.getTimeZoneKey())); assertExecute("current_timestamp", TIMESTAMP_WITH_TIME_ZONE, new SqlTimestampWithTimeZone(TEST_SESSION.getStartTime(), TEST_SESSION.getTimeZoneKey())); Futures.allAsList(futures).get(); }
@Test public void testCurrentDate() throws Exception { // current date is the time at midnight in the session time zone assertFunction("CURRENT_DATE", DateType.DATE, new SqlDate((int) epochDaysInZone(TIME_ZONE_KEY, session.getStartTime()))); }
@Test public void testCurrentTimestamp() { functionAssertions.assertFunction("current_timestamp", TIMESTAMP_WITH_TIME_ZONE, new SqlTimestampWithTimeZone(session.getStartTime(), session.getTimeZoneKey())); functionAssertions.assertFunction("now()", TIMESTAMP_WITH_TIME_ZONE, new SqlTimestampWithTimeZone(session.getStartTime(), session.getTimeZoneKey())); }
@Test public void testLocalTime() throws Exception { long millis = new LocalTime(session.getStartTime(), DATE_TIME_ZONE).getMillisOfDay(); functionAssertions.assertFunction("LOCALTIME", TimeType.TIME, toTime(millis)); }
@Test public void testCurrentTime() throws Exception { long millis = new LocalTime(session.getStartTime(), DATE_TIME_ZONE).getMillisOfDay(); functionAssertions.assertFunction("CURRENT_TIME", TIME_WITH_TIME_ZONE, new SqlTimeWithTimeZone(millis, session.getTimeZoneKey())); }
.setRemoteUserAddress(session.getRemoteUserAddress().orElse(null)) .setUserAgent(session.getUserAgent().orElse(null)) .setStartTime(session.getStartTime()) .build();
private static void assertEqualSessions(Session actual, Session expected) { assertEquals(actual.getQueryId(), expected.getQueryId()); assertEquals(actual.getTransactionId(), expected.getTransactionId()); assertEquals(actual.getIdentity(), expected.getIdentity()); assertEquals(actual.getSource(), expected.getSource()); assertEquals(actual.getCatalog(), expected.getCatalog()); assertEquals(actual.getSchema(), expected.getSchema()); assertEquals(actual.getTimeZoneKey(), expected.getTimeZoneKey()); assertEquals(actual.getLocale(), expected.getLocale()); assertEquals(actual.getRemoteUserAddress(), expected.getRemoteUserAddress()); assertEquals(actual.getUserAgent(), expected.getUserAgent()); assertEquals(actual.getStartTime(), expected.getStartTime()); assertEquals(actual.getSystemProperties(), expected.getSystemProperties()); assertEquals(actual.getCatalogProperties(), expected.getCatalogProperties()); } }
getSession().getClientCapabilities(), getSession().getResourceEstimates(), getSession().getStartTime(), ImmutableMap.<String, String>builder() .put("test_string", "foo string")
defaultSession.getRemoteUserAddress(), defaultSession.getUserAgent(), defaultSession.getStartTime(), defaultSession.getSystemProperties(), defaultSession.getCatalogProperties(),