@Test public void testIsSelect() { { String sql = "select ( date '2001-09-28' + interval floor(1.2) day) from test_kylin_fact"; boolean selectStatement = QueryUtil.isSelectStatement(sql); Assert.assertEquals(true, selectStatement); } { String sql = " Select ( date '2001-09-28' + interval floor(1.2) day) from test_kylin_fact"; boolean selectStatement = QueryUtil.isSelectStatement(sql); Assert.assertEquals(true, selectStatement); } { String sql = " \n" + "Select ( date '2001-09-28' + interval floor(1.2) day) from test_kylin_fact"; boolean selectStatement = QueryUtil.isSelectStatement(sql); Assert.assertEquals(true, selectStatement); } { String sql = "--comment\n" + " Select ( date '2001-09-28' + interval floor(1.2) day) from test_kylin_fact"; boolean selectStatement = QueryUtil.isSelectStatement(sql); Assert.assertEquals(true, selectStatement); } { String sql = " UPDATE Customers\n" + "SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'\n" + "WHERE CustomerID = 1;"; boolean selectStatement = QueryUtil.isSelectStatement(sql); Assert.assertEquals(false, selectStatement); } { String sql = " explain plan for select count(*) from test_kylin_fact\n"; boolean selectStatement = QueryUtil.isSelectStatement(sql); Assert.assertEquals(true, selectStatement); } }
public static boolean isSelectStatement(String sql) { String sql1 = sql.toLowerCase(Locale.ROOT); sql1 = removeCommentInSql(sql1); sql1 = sql1.trim(); return sql1.startsWith(KEYWORD_SELECT) || (sql1.startsWith(KEYWORD_WITH) && sql1.contains(KEYWORD_SELECT)) || (sql1.startsWith(KEYWORD_EXPLAIN) && sql1.contains(KEYWORD_SELECT)); }
QueryUtil { public static boolean isSelectStatement(String sql) { String sql1 = sql.toLowerCase(Locale.ROOT); sql1 = removeCommentInSql(sql1); sql1 = sql1.trim(); return sql1.startsWith(KEYWORD_SELECT) || (sql1.startsWith(KEYWORD_WITH) && sql1.contains(KEYWORD_SELECT)) || (sql1.startsWith(KEYWORD_EXPLAIN) && sql1.contains(KEYWORD_SELECT)); } }
QueryUtil { public static boolean isSelectStatement(String sql) { String sql1 = sql.toLowerCase(Locale.ROOT); sql1 = removeCommentInSql(sql1); sql1 = sql1.trim(); return sql1.startsWith(KEYWORD_SELECT) || (sql1.startsWith(KEYWORD_WITH) && sql1.contains(KEYWORD_SELECT)) || (sql1.startsWith(KEYWORD_EXPLAIN) && sql1.contains(KEYWORD_SELECT)); } private  QueryUtil(); }
QueryUtil { public static boolean isSelectStatement(String sql) { String sql1 = sql.toLowerCase(Locale.ROOT); sql1 = removeCommentInSql(sql1); sql1 = sql1.trim(); return sql1.startsWith(KEYWORD_SELECT) || (sql1.startsWith(KEYWORD_WITH) && sql1.contains(KEYWORD_SELECT)) || (sql1.startsWith(KEYWORD_EXPLAIN) && sql1.contains(KEYWORD_SELECT)); } private  QueryUtil(); static String appendLimitOffsetToSql(String sql, int limit, int offset); @Deprecated static String massageSql(String sql, String project, int limit, int offset, String defaultSchema); static String massageSql(String sql, String project, int limit, int offset, String defaultSchema,
            String catalog); static String makeErrorMsgUserFriendly(Throwable e); static String makeErrorMsgUserFriendly(String errorMsg); static boolean isSelectStatement(String sql); static String removeCommentInSql(String sql1); }
QueryUtil { public static boolean isSelectStatement(String sql) { String sql1 = sql.toLowerCase(Locale.ROOT); sql1 = removeCommentInSql(sql1); sql1 = sql1.trim(); return sql1.startsWith(KEYWORD_SELECT) || (sql1.startsWith(KEYWORD_WITH) && sql1.contains(KEYWORD_SELECT)) || (sql1.startsWith(KEYWORD_EXPLAIN) && sql1.contains(KEYWORD_SELECT)); } private  QueryUtil(); static String appendLimitOffsetToSql(String sql, int limit, int offset); @Deprecated static String massageSql(String sql, String project, int limit, int offset, String defaultSchema); static String massageSql(String sql, String project, int limit, int offset, String defaultSchema,
            String catalog); static String makeErrorMsgUserFriendly(Throwable e); static String makeErrorMsgUserFriendly(String errorMsg); static boolean isSelectStatement(String sql); static String removeCommentInSql(String sql1);  }