예제 #1
0
  @Test
  public void testUDAggregate() throws Exception {
    String ddl =
        "CREATE VIRTUAL FUNCTION SourceFunc(flag boolean, msg varchar) RETURNS varchar "
            + "OPTIONS(CATEGORY 'misc', AGGREGATE 'true', \"allows-distinct\" 'true', UUID 'y')";

    Schema s = helpParse(ddl, "model").getSchema();

    FunctionMethod fm = s.getFunction("y");
    assertNotNull(fm);
    assertEquals("string", fm.getOutputParameter().getType());
    assertEquals(FunctionMethod.PushDown.CAN_PUSHDOWN, fm.getPushdown());
    assertEquals(2, fm.getInputParameterCount());
    assertEquals("flag", fm.getInputParameters().get(0).getName());
    assertEquals("boolean", fm.getInputParameters().get(0).getType());
    assertEquals("msg", fm.getInputParameters().get(1).getName());
    assertEquals("string", fm.getInputParameters().get(1).getType());
    assertFalse(fm.getInputParameters().get(1).isVarArg());
    assertNotNull(fm.getAggregateAttributes());
    assertTrue(fm.getAggregateAttributes().allowsDistinct());
    assertEquals(FunctionMethod.Determinism.DETERMINISTIC, fm.getDeterminism());
    assertEquals("misc", fm.getCategory());
    assertFalse(fm.isNullOnNull());
  }