@Test public void testDateAggFunction() throws Exception{ String query = "SELECT max(cast(HIRE_DATE as date)) as MAX_DATE, min(cast(HIRE_DATE as date)) as MIN_DATE" + " FROM `employee.json`"; String t = new Date(ISOChronology.getInstance().getDateTimeMillis(1998, 1, 1, 0)).toString(); String t1 = new Date(ISOChronology.getInstance().getDateTimeMillis(1993, 5, 1, 0)).toString(); String result = "MAX_DATE="+ t + "; " + "MIN_DATE=" + t1 + "\n"; withFull("cp") .sql(query) .returns(result); }
@Test public void testCurrentDateTimezone() { TimeZoneKey kievTimeZoneKey = getTimeZoneKey("Europe/Kiev"); TimeZoneKey bahiaBanderasTimeZoneKey = getTimeZoneKey("America/Bahia_Banderas"); // The zone has 'gap' on 1970-01-01 TimeZoneKey montrealTimeZoneKey = getTimeZoneKey("America/Montreal"); long timeIncrement = TimeUnit.MINUTES.toMillis(53); // We expect UTC millis later on so we have to use UTC chronology for (long instant = ISOChronology.getInstanceUTC().getDateTimeMillis(2000, 6, 15, 0, 0, 0, 0); instant < ISOChronology.getInstanceUTC().getDateTimeMillis(2016, 6, 15, 0, 0, 0, 0); instant += timeIncrement) { assertCurrentDateAtInstant(kievTimeZoneKey, instant); assertCurrentDateAtInstant(bahiaBanderasTimeZoneKey, instant); assertCurrentDateAtInstant(montrealTimeZoneKey, instant); assertCurrentDateAtInstant(TIME_ZONE_KEY, instant); } }
public static long getDate(ArrowBuf buf, int start, int end){ if (BoundsChecking.BOUNDS_CHECKING_ENABLED) { buf.checkBytes(start, end); } int[] dateFields = memGetDate(buf.memoryAddress(), start, end); return CHRONOLOGY.getDateTimeMillis(dateFields[0], dateFields[1], dateFields[2], 0); }
public static long getDate(DrillBuf buf, int start, int end){ rangeCheck(buf, start, end); int[] dateFields = memGetDate(buf.memoryAddress(), start, end); return CHRONOLOGY.getDateTimeMillis(dateFields[0], dateFields[1], dateFields[2], 0); }
@Test public void testDateAggFunction() throws Exception{ String query = new String("SELECT max(cast(HIRE_DATE as date)) as MAX_DATE, min(cast(HIRE_DATE as date)) as MIN_DATE" + " FROM \"employee.json\""); String t = new Date(ISOChronology.getInstance().getDateTimeMillis(1998, 1, 1, 0)).toString(); String t1 = new Date(ISOChronology.getInstance().getDateTimeMillis(1993, 5, 1, 0)).toString(); //String t = new Date(1998, 1, 1).toString(); //String t1 = new Date(1993, 5, 1).toString(); String result = String.format("MAX_DATE="+ t + "; " + "MIN_DATE=" + t1 + "\n"); JdbcAssert.withFull(sabotNode.getJDBCConnectionString(), "cp") .sql(query) .returns(result); }
@Test public void testCurrentDateTimezone() { TimeZoneKey kievTimeZoneKey = getTimeZoneKey("Europe/Kiev"); TimeZoneKey bahiaBanderasTimeZoneKey = getTimeZoneKey("America/Bahia_Banderas"); // The zone has 'gap' on 1970-01-01 TimeZoneKey montrealTimeZoneKey = getTimeZoneKey("America/Montreal"); long timeIncrement = TimeUnit.MINUTES.toMillis(53); // We expect UTC millis later on so we have to use UTC chronology for (long instant = ISOChronology.getInstanceUTC().getDateTimeMillis(2000, 6, 15, 0, 0, 0, 0); instant < ISOChronology.getInstanceUTC().getDateTimeMillis(2016, 6, 15, 0, 0, 0, 0); instant += timeIncrement) { assertCurrentDateAtInstant(kievTimeZoneKey, instant); assertCurrentDateAtInstant(bahiaBanderasTimeZoneKey, instant); assertCurrentDateAtInstant(montrealTimeZoneKey, instant); assertCurrentDateAtInstant(TIME_ZONE_KEY, instant); } }
@Test public void testCurrentDateTimezone() { TimeZoneKey kievTimeZoneKey = getTimeZoneKey("Europe/Kiev"); TimeZoneKey bahiaBanderasTimeZoneKey = getTimeZoneKey("America/Bahia_Banderas"); // The zone has 'gap' on 1970-01-01 TimeZoneKey montrealTimeZoneKey = getTimeZoneKey("America/Montreal"); long timeIncrement = TimeUnit.MINUTES.toMillis(53); // We expect UTC millis later on so we have to use UTC chronology for (long instant = ISOChronology.getInstanceUTC().getDateTimeMillis(2000, 6, 15, 0, 0, 0, 0); instant < ISOChronology.getInstanceUTC().getDateTimeMillis(2016, 6, 15, 0, 0, 0, 0); instant += timeIncrement) { assertCurrentDateAtInstant(kievTimeZoneKey, instant); assertCurrentDateAtInstant(bahiaBanderasTimeZoneKey, instant); assertCurrentDateAtInstant(montrealTimeZoneKey, instant); assertCurrentDateAtInstant(TIME_ZONE_KEY, instant); } }