/** * Should only work for string literals, not with the keyword */ @Test public void testIncompleteTimestampDateLiteral() { helpException("DATE '2000-01-01 00:00'"); }
/** SELECT * FROM g1 inner join g2 */ @Test public void testInvalidInnerJoin() { helpException("SELECT * FROM g1 inner join g2"); //$NON-NLS-1$ }
/** SELECT a FROM m.g GROUP BY a, b AS x */ @Test public void testFailAliasInHaving() { helpException("SELECT a FROM m.g GROUP BY a, b AS x"); //$NON-NLS-1$ }
/** SELECT a WHERE a = 'aString' */ @Test public void testFailsNoFromClause(){ helpException("SELECT a WHERE a = 'aString'"); //$NON-NLS-1$ }
@Test public void testBadAlias() { String sql = "select a as a.x from foo"; //$NON-NLS-1$ helpException(sql, "TEIID31100 Parsing error: Encountered \"select a as [*]a.x[*] from foo\" at line 1, column 13.\nInvalid alias format: [a.x]"); //$NON-NLS-1$ }
/** SELECT or.a FROM g AS or */ @Test public void testAliasInFromUsingKeywordFails(){ helpException("SELECT or.a FROM g AS or"); //$NON-NLS-1$ }
/** SELECT {t 'xyz'} FROM m.g1 */ @Test public void testTimeLiteralFail() { helpException("SELECT {t 'xyz'} FROM m.g1"); //$NON-NLS-1$ }
/** SELECT xx.yy%.a from xx.yy */ @Test public void testFailsWildcardInSelect(){ helpException("SELECT xx.yy%.a from xx.yy", "TEIID31100 Parsing error: Encountered \"SELECT xx.yy[*]%[*].a\" at line 1, column 13.\nLexical error. Character is not a valid token: % "); //$NON-NLS-1$ }
/** SELECT a, b FROM (SELECT c FROM m.g2) */ @Test public void testSubqueryInvalid() { helpException("SELECT a, b FROM (SELECT c FROM m.g2)"); //$NON-NLS-1$ }
/** SELECT {d'bad'} FROM m.g1 */ @Test public void testDateLiteralFail() { helpException("SELECT {d'bad'} FROM m.g1"); //$NON-NLS-1$ }
/** SELECT a AS or FROM g */ @Test public void testAliasInSelectUsingKeywordFails(){ helpException("SELECT a AS or FROM g"); //$NON-NLS-1$ }
/** FROM g WHERE a = 'aString' */ @Test public void testFailsNoSelectClause(){ helpException("FROM g WHERE a = 'aString'"); //$NON-NLS-1$ }
/** SELECT a from g ORDER BY b DSC*/ @Test public void testFailsDSCMisspelled(){ helpException("SELECT a from g ORDER BY b DSC"); //$NON-NLS-1$ }
@Test public void testUnionJoin1() { String sql = "select * from pm1.g1 union all join pm1.g2 where g1.e1 = 1"; //$NON-NLS-1$ helpException(sql); }
@Test public void testInvalidAlias() { String sql = "SELECT 1 from y AS \"bad\".\"name\""; helpException(sql); //$NON-NLS-1$ }
/** SELECT a FROM m.g GROUP BY a, b HAVING COUNT(AVG(b)) */ @Test public void testFailNestedAggregateInHaving() { helpException("SELECT a FROM m.g GROUP BY a, b HAVING COUNT(b) AS x = 5"); //$NON-NLS-1$ }
@Test public void testBadScalarSubqueryExpression() { helpException("SELECT e1, length(SELECT e1 FROM m.g1) as X FROM m.g2"); //$NON-NLS-1$ }
@Test public void testTextTableColumns() throws Exception { helpException("SELECT * from texttable(foo x string)"); }
@Ignore @Test public void testEmptyOuterJoinCriteria() { helpException("select a from b left outer join c on ()"); //$NON-NLS-1$ }
@Test public void testAliasInSingleQuotes() throws Exception { GroupSymbol g = new GroupSymbol("x.y.z"); //$NON-NLS-1$ From from = new From(); from.addGroup(g); AliasSymbol as = new AliasSymbol("fooAlias", new ElementSymbol("fooKey")); //$NON-NLS-1$ //$NON-NLS-2$ Select select = new Select(); select.addSymbol(as); Query query = new Query(); query.setSelect(select); query.setFrom(from); helpException("SELECT fooKey 'fooAlias' FROM x.\"y\".z"); //$NON-NLS-1$ }