Пример #1
0
  @Test
  public void testDDLMetadata() throws Exception {
    String ddl =
        "CREATE VIRTUAL FUNCTION SourceFunc(msg varchar) RETURNS varchar "
            + "OPTIONS(CATEGORY 'misc', DETERMINISM 'DETERMINISTIC', "
            + "\"NULL-ON-NULL\" 'true', JAVA_CLASS '"
            + TestFunctionPushdown.class.getName()
            + "', JAVA_METHOD 'sourceFunc');"
            + "CREATE VIEW X (Y varchar) as SELECT e1 from pm1.g1;";

    MetadataFactory mf = TestDDLParser.helpParse(ddl, "model");
    mf.getSchema().setPhysical(false);
    MetadataStore ms = mf.asMetadataStore();
    ms.merge(RealMetadataFactory.example1Cached().getMetadataStore());

    QueryMetadataInterface metadata =
        RealMetadataFactory.createTransformationMetadata(ms, "example1");

    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
    caps.setFunctionSupport("model.SourceFunc", true);
    capFinder.addCapabilities("pm1", caps); // $NON-NLS-1$

    helpPlan(
        "select sourceFunc(y) from x",
        metadata,
        null,
        capFinder,
        new String[] {"SELECT sourceFunc(g_0.e1) FROM pm1.g1 AS g_0"},
        ComparisonMode.EXACT_COMMAND_STRING); // $NON-NLS-1$

    caps.setFunctionSupport("model.SourceFunc", false);

    helpPlan(
        "select sourceFunc(y) from x",
        metadata,
        null,
        capFinder,
        new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"},
        ComparisonMode.EXACT_COMMAND_STRING); // $NON-NLS-1$
  }