use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestQueryRewriter method testRewriteInNotHashable.
@Test
public void testRewriteInNotHashable() throws Exception {
Constant c = new Constant(new FakeObject(0));
// $NON-NLS-1$
SetCriteria crit = new SetCriteria(c, new ArrayList<Constant>());
crit.getValues().add(new Constant(new FakeObject(1)));
crit.getValues().add(new Constant(new FakeObject(2)));
Criteria actual = QueryRewriter.rewriteCriteria(crit, null, null);
assertEquals(QueryRewriter.TRUE_CRITERIA, actual);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestQueryRewriter method testRewriteCrit_formatDouble.
@Ignore(value = "Cannot deterime if the format is narrowing")
@Test
public void testRewriteCrit_formatDouble() throws Exception {
// $NON-NLS-1$
String original = "formatDouble(convert(pm1.g1.e4, double), '$#,##0.00') = '$1,234.50'";
// $NON-NLS-1$
String expected = "pm1.g1.e4 = '1234.5'";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
Criteria origCrit = parseCriteria(original, metadata);
Criteria expectedCrit = parseCriteria(expected, metadata);
((CompareCriteria) expectedCrit).setRightExpression(new Constant(new Double(1234.5)));
// rewrite
Criteria actual = QueryRewriter.rewriteCriteria(origCrit, null, null);
// $NON-NLS-1$
assertEquals("Did not rewrite correctly: ", expectedCrit, actual);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestQueryRewriter method testStoredProcedure_9822.
// defect 9822
@Test
public void testStoredProcedure_9822() throws Exception {
QueryParser parser = new QueryParser();
// $NON-NLS-1$
Command command = parser.parseCommand("exec pm1.sp4(5)");
// resolve
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
QueryResolver.resolveCommand(command, metadata);
// rewrite
Command rewriteCommand = QueryRewriter.rewrite(command, metadata, null);
Collection<SPParameter> parameters = ((StoredProcedure) rewriteCommand).getParameters();
for (SPParameter param : parameters) {
if (param.getParameterType() == ParameterInfo.IN || param.getParameterType() == ParameterInfo.INOUT) {
assertTrue(param.getExpression() instanceof Constant);
}
}
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestAliasSymbol method testClone.
@Test
public void testClone() {
// $NON-NLS-1$ //$NON-NLS-2$
AliasSymbol a1 = new AliasSymbol("X", new ExpressionSymbol("x", new Constant(1)));
// $NON-NLS-1$
a1.setOutputName("foo");
AliasSymbol clone = (AliasSymbol) a1.clone();
assertEquals(a1, clone);
assertEquals(a1.getOutputName(), clone.getOutputName());
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestCompoundCriteria method testClone2.
public void testClone2() {
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("e1");
// $NON-NLS-1$
CompareCriteria ccrit1 = new CompareCriteria(e1, CompareCriteria.EQ, new Constant("abc"));
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.AND, ccrit1, null);
UnitTestUtil.helpTestEquivalence(0, comp, comp.clone());
}
Aggregations