public static List < String > getColumnListFromQuery ( String query ) { if ( Strings . isNullOrEmpty ( query ) ) { return null ; } String queryLowerCase = query . toLowerCase ( ) ; int startIndex = queryLowerCase . indexOf ( "select " ) + 7 ; int endIndex = queryLowerCase . indexOf ( " from " ) ; if ( startIndex < 0 || endIndex < 0 ) { return null ; } String [ ] inputQueryColumns = query . substring ( startIndex , endIndex ) . toLowerCase ( ) . replaceAll ( " " , "" ) . split ( "," ) ; return Arrays . asList ( inputQueryColumns ) ; }
get column list from the user provided query to build schema with the respective columns