public void testDistinct() throws JSQLParserException { String statement = "SELECT DISTINCT ON (myid) myid, mycol FROM mytable WHERE mytable.col = 9"; PlainSelect plainSelect = (PlainSelect) ((Select) parserManager.parse(new StringReader(statement))).getSelectBody(); assertEquals( "myid", ((Column) ((SelectExpressionItem) plainSelect.getDistinct().getOnSelectItems().get(0)) .getExpression()) .getColumnName()); assertEquals( "mycol", ((Column) ((SelectExpressionItem) plainSelect.getSelectItems().get(1)).getExpression()) .getColumnName()); assertEquals(statement.toUpperCase(), plainSelect.toString().toUpperCase()); }