QueryCommand extends MultiClusterCommandBase { public static QueryCommand parse(String commandString, ExecutionContext sessionContext) { boolean isSelect = false; commandString = commandString.trim(); if (commandString.toUpperCase().matches("^SELECT[\\s\\S]*")) { isSelect = true; } if (!commandString.endsWith(";")) { commandString = commandString + ";"; } return new QueryCommand(isSelect, commandString, sessionContext); } QueryCommand(boolean isSelect, String commandText, ExecutionContext context); void run(); String getTaskName(); String getInstanceId(); boolean isSelectCommand(); static QueryCommand parse(String commandString, ExecutionContext sessionContext);  }
@Test public void testParse() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); for (String cmd : selectCommandStrings) { QueryCommand command = QueryCommand.parse(cmd, context); assertNotNull(command); Assert.assertTrue(command.isSelectCommand()); } for (String cmd : queryCommandStrings) { QueryCommand command = QueryCommand.parse(cmd, context); assertNotNull(command); Assert.assertFalse(command.isSelectCommand()); } }