StormSqlExpression extends ExpressionRuntime { public List<String> createFunctions() { List<String> result = new ArrayList<>(); result.addAll(doCreateFunctions(functions)); result.addAll(doCreateFunctions(aggregateFunctions)); return result; } StormSqlExpression(Condition condition);  StormSqlExpression(Condition condition, Projection projection);  StormSqlExpression(Condition condition, Projection projection, GroupBy groupBy, Having having); @Override String asString(); List<String> createFunctions(); String createTable(String schemaName); String select(); List<Schema.Field> getStormSqlFields(); void addStormSqlField(Schema.Field field); List<String> getProjectedFields(); List<String> getOutputFields(); static final String RULE_SCHEMA; }
@Test public void testCreateFunctionDuplicate() throws Exception { Condition condition = new Condition(); Expression f1 = new FunctionExpression("FLOOR", "com.hortonworks.streamline.Floor", ImmutableList.of(new Literal("100.5"))); Expression f2 = new FunctionExpression("FLOOR", "com.hortonworks.streamline.Floor", ImmutableList.of(new Literal("2.5"))); Expression expression1 = new BinaryExpression(Operator.GREATER_THAN, new FieldExpression(Schema.Field.of("x", Schema.Type.INTEGER)), f1); Expression expression2 = new BinaryExpression(Operator.GREATER_THAN, new FieldExpression(Schema.Field.of("x", Schema.Type.INTEGER)), f2); Expression expression = new BinaryExpression(Operator.AND, expression1, expression2); condition.setExpression(expression); stormSqlExpression = new StormSqlExpression(condition); assertEquals(Arrays.asList("CREATE FUNCTION FLOOR AS 'com.hortonworks.streamline.Floor'"), stormSqlExpression.createFunctions()); }