@Test public void testfillPredicatesForSideTable() throws SqlParseException { String testSql = "insert \n" + "into\n" + " MyResult\n" + " select\n" + " MyTable.a,\n" + " MyTable.b,\n" + " s.c,\n" + " s.d\n" + " from\n" + " MyTable\n" + " join\n" + " sideTable s\n" + " on MyTable.a = s.c\n" + " where\n" + " MyTable.a='1' and s.d='1' and s.d <> '3' and s.c LIKE '%xx%' and s.c in ('1','2') and s.c between '10' and '23' and s.d is not null\n"; AbstractSideTableInfo sideTableInfo = new AbstractSideTableInfo(){ @Override public boolean check() { return false; } }; sideTableInfo.setName("sideTable"); Map<String, AbstractSideTableInfo> sideTableMap = new HashMap<>(); sideTableMap.put("sideTable", sideTableInfo); SidePredicatesParser sidePredicatesParser = new SidePredicatesParser(); sidePredicatesParser.fillPredicatesForSideTable(testSql, sideTableMap); List<PredicateInfo> sideTablePredicateInfoes = sideTableMap.get("sideTable").getPredicateInfoes(); List<PredicateInfo> expectedsPredicateInfoes = new ArrayList<>(); expectedsPredicateInfoes.add(PredicateInfo.builder().setOperatorName("=").setOperatorKind("EQUALS").setOwnerTable("s").setFieldName("d").setCondition("'1'").build()); expectedsPredicateInfoes.add(PredicateInfo.builder().setOperatorName("<>").setOperatorKind("NOT_EQUALS").setOwnerTable("s").setFieldName("d").setCondition("'3'").build()); expectedsPredicateInfoes.add(PredicateInfo.builder().setOperatorName("LIKE").setOperatorKind("LIKE").setOwnerTable("s").setFieldName("c").setCondition("'%xx%'").build()); expectedsPredicateInfoes.add(PredicateInfo.builder().setOperatorName("IN").setOperatorKind("IN").setOwnerTable("s").setFieldName("c").setCondition("'1', '2'").build()); expectedsPredicateInfoes.add(PredicateInfo.builder().setOperatorName("BETWEEN ASYMMETRIC").setOperatorKind("BETWEEN").setOwnerTable("s").setFieldName("c").setCondition("'10' AND '23'").build()); expectedsPredicateInfoes.add(PredicateInfo.builder().setOperatorName("IS NOT NULL").setOperatorKind("IS_NOT_NULL").setOwnerTable("s").setFieldName("d").setCondition("s.d").build()); Assert.assertEquals(expectedsPredicateInfoes.toString(), sideTablePredicateInfoes.toString()); }
public void fillPredicatesForSideTable(String exeSql, Map<String, AbstractSideTableInfo> sideTableMap) throws SqlParseException { SqlNode sqlNode = flinkPlanner.getParser().parse(exeSql); parseSql(sqlNode, sideTableMap, Maps.newHashMap()); }
SidePredicatesParser { public void fillPredicatesForSideTable(String exeSql, Map<String, AbstractSideTableInfo> sideTableMap) throws SqlParseException { SqlNode sqlNode = flinkPlanner.getParser().parse(exeSql); parseSql(sqlNode, sideTableMap, Maps.newHashMap()); } }
SidePredicatesParser { public void fillPredicatesForSideTable(String exeSql, Map<String, AbstractSideTableInfo> sideTableMap) throws SqlParseException { SqlNode sqlNode = flinkPlanner.getParser().parse(exeSql); parseSql(sqlNode, sideTableMap, Maps.newHashMap()); }  }
SidePredicatesParser { public void fillPredicatesForSideTable(String exeSql, Map<String, AbstractSideTableInfo> sideTableMap) throws SqlParseException { SqlNode sqlNode = flinkPlanner.getParser().parse(exeSql); parseSql(sqlNode, sideTableMap, Maps.newHashMap()); }  void fillPredicatesForSideTable(String exeSql, Map<String, AbstractSideTableInfo> sideTableMap); }
SidePredicatesParser { public void fillPredicatesForSideTable(String exeSql, Map<String, AbstractSideTableInfo> sideTableMap) throws SqlParseException { SqlNode sqlNode = flinkPlanner.getParser().parse(exeSql); parseSql(sqlNode, sideTableMap, Maps.newHashMap()); }  void fillPredicatesForSideTable(String exeSql, Map<String, AbstractSideTableInfo> sideTableMap);  }