public Interval getTimeBoundary ( String dataSource , Map < String , String > reqHeaders ) throws IllegalAccessException { Program < BaseStatementMeta > pgm = DCompiler . compileSql ( format ( "SELECT FROM %s" , dataSource ) ) ; Either < String , Either < Mapper4All , JSONArray > > res = fireQuery ( pgm . nthStmnt ( 0 ) . toString ( ) , reqHeaders , true ) ; if ( res . isLeft ( ) ) { throw new IllegalAccessException ( format ( "DataSource %s does not exist(or) check if druid is accessible, faced exception %s" , dataSource , res . left ( ) . get ( ) ) ) ; } Mapper4All finalRes = res . right ( ) . get ( ) . left ( ) . get ( ) ; // Thats because we know Time boundary cannot be a Join result!! int min = finalRes . baseFieldNames . indexOf ( "minTime" ) ; int max = finalRes . baseFieldNames . indexOf ( "maxTime" ) ; if ( finalRes . baseAllRows . isEmpty ( ) ) { // Possible when table does not exist. throw new IllegalAccessException ( "Either table does not exist(or) druid is not accessible" ) ; } List < Object > row = finalRes . baseAllRows . get ( 0 ) ; // Only 1 element is returned in Timeboundary. return new Interval ( row . get ( min ) . toString ( ) , row . get ( max ) . toString ( ) ) ; }
Get timeboundary .