@Test public void testElementId() throws Exception { TransformationMetadata tm = exampleTransformationMetadata(); tm.getElementID("x.FoO.coL"); }
/** * Time Criteria - case using invalid max and min time strings */ @Test public void testEstimateCostOfCriteriaTime2() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Column e3 = metadata.getElementID("pm3.g1.e3"); //$NON-NLS-1$ e3.setMinimumValue("2007-04-03 12:12:12.10"); //$NON-NLS-1$ e3.setMaximumValue("2007-06-03 12:12:12.10"); //$NON-NLS-1$ String critString = "pm3.g1.e3 <= {t'11:11:11'}"; //$NON-NLS-1$ helpTestEstimateCost(critString, 100, 33, metadata); }
/** * Date Criteria - Case using valid max and min date strings. In the case of date, * the valid strings are timestamp format - since that is what our costing sets them as. */ @Test public void testEstimateCostOfCriteriaDate1() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Column e2 = metadata.getElementID("pm3.g1.e2"); //$NON-NLS-1$ e2.setMinimumValue("2007-04-03 12:12:12.10"); //$NON-NLS-1$ e2.setMaximumValue("2007-06-03 12:12:12.10"); //$NON-NLS-1$ String critString = "pm3.g1.e2 <= {d'2008-04-03'}"; //$NON-NLS-1$ helpTestEstimateCost(critString, 100, 100, metadata); }
/** * Date Criteria - Case using invalid max and min date strings. In the case of date, * one example of invalid strings is date format - since our costing sets them to timestamp. */ @Test public void testEstimateCostOfCriteriaDate2() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Column e2 = metadata.getElementID("pm3.g1.e2"); //$NON-NLS-1$ e2.setMinimumValue("2007-04-03"); //$NON-NLS-1$ e2.setMaximumValue("2007-06-03"); //$NON-NLS-1$ String critString = "pm3.g1.e2 <= {d'2008-04-03'}"; //$NON-NLS-1$ helpTestEstimateCost(critString, 100, 33, metadata); }
/** * Timestamp Criteria - case using valid max and min timestamp strings */ @Test public void testEstimateCostOfCriteriaTimestamp1() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Column e4 = metadata.getElementID("pm3.g1.e4"); //$NON-NLS-1$ e4.setMinimumValue("2007-04-03 12:12:12.10"); //$NON-NLS-1$ e4.setMaximumValue("2007-04-03 12:12:12.10"); //$NON-NLS-1$ String critString = "pm3.g1.e4 <= {ts'2007-04-03 12:12:12.10'}"; //$NON-NLS-1$ helpTestEstimateCost(critString, 100, 1, metadata); }
/** * Time Criteria - case using valid max and min time strings. */ @Test public void testEstimateCostOfCriteriaTime1() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Column e3 = metadata.getElementID("pm3.g1.e3"); //$NON-NLS-1$ e3.setMinimumValue("12:12:12"); //$NON-NLS-1$ e3.setMaximumValue("12:13:14"); //$NON-NLS-1$ String critString = "pm3.g1.e3 <= {t'11:11:11'}"; //$NON-NLS-1$ helpTestEstimateCost(critString, 100, 1, metadata); }
/** * Timestamp Criteria - case using invalid max and min timestamp strings */ @Test public void testEstimateCostOfCriteriaTimestamp2() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Column e4 = metadata.getElementID("pm3.g1.e4"); //$NON-NLS-1$ e4.setMinimumValue("2007-04-03"); //$NON-NLS-1$ e4.setMaximumValue("2007-06-03"); //$NON-NLS-1$ String critString = "pm3.g1.e4 <= {ts'2007-04-03 12:12:12.10'}"; //$NON-NLS-1$ helpTestEstimateCost(critString, 100, 33, metadata); }
@Test public void testDefect21389() throws Exception{ String sql = "CREATE VIRTUAL PROCEDURE BEGIN SELECT * INTO #temptable FROM pm1.g1; INSERT INTO #temptable (e1) VALUES ('a'); END"; //$NON-NLS-1$ TransformationMetadata metadata = RealMetadataFactory.example1(); Column c = metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$ c.setUpdatable(false); Command command = new QueryParser().parseCommand(sql); QueryResolver.resolveCommand(command, metadata); // Validate ValidatorReport report = Validator.validate(command, metadata); // Validate assertEquals(0, report.getItems().size()); }
fakeMetadata.getElementID("pm1.g1.e1").setDistinctValues(1); fakeMetadata.getElementID("pm1.g1.e2").setDistinctValues(1); fakeMetadata.getElementID("pm6.g1.e1").setDistinctValues(1000); fakeMetadata.getElementID("pm6.g1.e2").setDistinctValues(1000);
fakeMetadata.getGroupID("pm1.g1").getAccessPatterns().clear(); RealMetadataFactory.setCardinality("pm1.g1", 1000, fakeMetadata); fakeMetadata.getElementID("pm1.g1.e1").setDistinctValues(40); RealMetadataFactory.setCardinality("pm3.g1", 1, fakeMetadata); fakeMetadata.getElementID("pm3.g1.e1").setDistinctValues(1);
@Test public void testAntiSemiJoinInHint() throws Exception { TransformationMetadata example4 = RealMetadataFactory.example4(); example4.getElementID("pm3.g1.e2").setNullType(NullType.No_Nulls); ProcessorPlan plan = helpPlan("Select e1 from pm1.g2 as o where e2 NOT IN /*+ MJ */ (select e2 from pm3.g1 where e1 = o.e1)", example4, //$NON-NLS-1$ new String[] { "SELECT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm1.g2 AS g_0 ORDER BY c_1, c_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ checkNodeTypes(plan, new int[] { 1, // Access 0, // DependentAccess 0, // DependentSelect 0, // DependentProject 0, // DupRemove 0, // Grouping 0, // NestedLoopJoinStrategy 1, // MergeJoinStrategy 0, // Null 1, // PlanExecution 1, // Project 0, // Select 0, // Sort 0 // UnionAll }); checkJoinCounts(plan, 0, 1); }
@Test public void testSetCriteria5() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Object modelID = metadata.getMetadataStore().getSchema("PM1"); Column elementID = metadata.getElementID("pm1.g1.e1"); elementID.setSearchType(SearchType.Like_Only); FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.CRITERIA_IN, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ helpTestVisitor("pm1.g1.e1 IN ('x')", modelID, metadata, capFinder, false, false); //$NON-NLS-1$ }
@Test public void testCompareCriteriaSearchableFail() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Object modelID = metadata.getMetadataStore().getSchema("PM1"); Column e1 = metadata.getElementID("pm1.g1.e1"); e1.setSearchType(SearchType.Like_Only); FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ helpTestVisitor("pm1.g1.e1 = 'x'", modelID, metadata, capFinder, false, false); }
@Test public void testSubqueryCompareCriteriaSearchableFail() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Schema modelID = metadata.getMetadataStore().getSchema("PM1"); Column e1 = metadata.getElementID("pm1.g1.e1"); e1.setSearchType(SearchType.Like_Only); FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ helpTestVisitorWithCommand("SELECT e1 FROM pm1.g1 WHERE pm1.g1.e1 = ANY (SELECT e1 FROM pm1.g2)", modelID, metadata, capFinder, false, false); //$NON-NLS-1$ }
/** * Is null is not a comparison operation */ @Test public void testIsNull4() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Object modelID = metadata.getMetadataStore().getSchema("PM1"); Column e1 = metadata.getElementID("pm1.g1.e1"); e1.setSearchType(SearchType.Like_Only); FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.CRITERIA_ISNULL, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ helpTestVisitor("pm1.g1.e1 IS NULL", modelID, metadata, capFinder, true, false); }
@Test public void testMatchCriteriaMatchableFail() throws Exception { TransformationMetadata metadata = RealMetadataFactory.example1(); Object modelID = metadata.getMetadataStore().getSchema("PM1"); Column e1 = metadata.getElementID("pm1.g1.e1"); e1.setSearchType(SearchType.All_Except_Like); FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true); caps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ helpTestVisitor("pm1.g1.e1 LIKE 'x'", modelID, metadata, capFinder, false, false); //$NON-NLS-1$ }
RealMetadataFactory.setCardinality("bqt1.smalla", 1000, metadata); //$NON-NLS-1$ RealMetadataFactory.setCardinality("bqt2.smalla", 10000, metadata); //$NON-NLS-1$ Column fmo = metadata.getElementID("bqt1.smalla.intnum"); fmo.setDistinctValues(1000); Column floatnum = metadata.getElementID("bqt1.smalla.floatnum"); floatnum.setDistinctValues(800);
TransformationMetadata metadata = TestOptimizer.example1(); RealMetadataFactory.setCardinality("pm1.g1", 100, metadata); metadata.getElementID("pm2.g1.e1").setDistinctValues(1000); RealMetadataFactory.setCardinality("pm2.g1", 1000, metadata); CommandContext cc = new CommandContext();
Column c = qmi.getElementID(name); if (c == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31223,