CalcitePlanner extends AbstractSQLPlanner { static final boolean isDDL(String query) { return USE_DDL_PARSER.matcher(query).matches(); } CalcitePlanner(DBManager manager, PlansCache plansCache); @Override long getCacheSize(); @Override long getCacheHits(); @Override long getCacheMisses(); @Override void clearCache(); @Override TranslatedQuery translate(String defaultTableSpace, String query, List<Object> parameters, boolean scan, boolean allowCache, boolean returnValues, int maxRows); static int convertToHerdType(RelDataType type); static final String TABLE_CONSISTENCY_COMMAND; static final String TABLESPACE_CONSISTENCY_COMMAND; }
@Test public void testIsDdl() { assertTrue(CalcitePlanner.isDDL("CREATE TABLE")); assertTrue(CalcitePlanner.isDDL(" CREATE TABLE `sm_machine`")); assertTrue(CalcitePlanner.isDDL("CREATE TABLE `sm_machine` (\n" + " `ip` varchar(20) NOT NULL DEFAULT '',")); assertTrue(CalcitePlanner.isDDL("CREATE TABLE `sm_machine` (\n" + " `ip` varchar(20) NOT NULL DEFAULT '',\n" + " `firefox_version` int(50) DEFAULT NULL,\n" + " `chrome_version` int(50) DEFAULT NULL,\n" + " `ie_version` int(50) DEFAULT NULL,\n" + " `log` varchar(2000) DEFAULT NULL,\n" + " `offset` int(50) DEFAULT NULL,\n" + " PRIMARY KEY (`ip`)\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;")); assertTrue(CalcitePlanner.isDDL("creaTe TABLE")); assertTrue(CalcitePlanner.isDDL("alter table")); assertTrue(CalcitePlanner.isDDL("coMMIT transaction")); assertTrue(CalcitePlanner.isDDL("rollBACK transaction")); assertTrue(CalcitePlanner.isDDL("begin transaction")); assertTrue(CalcitePlanner.isDDL("drop table")); assertFalse(CalcitePlanner.isDDL("select * from")); assertFalse(CalcitePlanner.isDDL("explain select * from")); }