Search in sources :

Example 71 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestCreateDrop method testCreateTempTable2.

@Test
public void testCreateTempTable2() {
    Create create = new Create();
    // $NON-NLS-1$
    create.setTable(new GroupSymbol("tempTable"));
    List<ElementSymbol> columns = new ArrayList<ElementSymbol>();
    // $NON-NLS-1$
    ElementSymbol column = new ElementSymbol("c1");
    column.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
    columns.add(column);
    // $NON-NLS-1$
    column = new ElementSymbol("c2");
    column.setType(DataTypeManager.DefaultDataClasses.BYTE);
    columns.add(column);
    create.setElementSymbolsAsColumns(columns);
    create.getColumns().get(0).setNullType(NullType.No_Nulls);
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Create local TEMPORARY table tempTable(c1 boolean not null, c2 byte)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 boolean NOT NULL, c2 byte)", create);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Create(org.teiid.query.sql.lang.Create) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 72 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestCreateDrop method testDropTable.

@Test
public void testDropTable() {
    Drop drop = new Drop();
    // $NON-NLS-1$
    drop.setTable(new GroupSymbol("tempTable"));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("DROP table tempTable", "DROP TABLE tempTable", drop);
}
Also used : GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Drop(org.teiid.query.sql.lang.Drop) Test(org.junit.Test)

Example 73 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestCreateDrop method testTypeAliases.

@Test
public void testTypeAliases() {
    Create create = new Create();
    // $NON-NLS-1$
    create.setTable(new GroupSymbol("tempTable"));
    List<ElementSymbol> columns = new ArrayList<ElementSymbol>();
    // $NON-NLS-1$
    ElementSymbol column = new ElementSymbol("c1");
    column.setType(DataTypeManager.DefaultDataClasses.STRING);
    columns.add(column);
    // $NON-NLS-1$
    column = new ElementSymbol("c2");
    column.setType(DataTypeManager.DefaultDataClasses.BYTE);
    columns.add(column);
    // $NON-NLS-1$
    column = new ElementSymbol("c3");
    column.setType(DataTypeManager.DefaultDataClasses.SHORT);
    columns.add(column);
    // $NON-NLS-1$
    column = new ElementSymbol("c4");
    column.setType(DataTypeManager.DefaultDataClasses.FLOAT);
    columns.add(column);
    // $NON-NLS-1$
    column = new ElementSymbol("c5");
    column.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);
    columns.add(column);
    create.setElementSymbolsAsColumns(columns);
    // $NON-NLS-1$
    helpTest("Create local TEMPORARY table tempTable (c1 varchar, c2 tinyint, c3 smallint, c4 real, c5 decimal)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 varchar, c2 tinyint, c3 smallint, c4 real, c5 decimal)", create);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Create(org.teiid.query.sql.lang.Create) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 74 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestCreateDrop method testForeignTemp.

@Test
public void testForeignTemp() {
    Create create = new Create();
    // $NON-NLS-1$
    create.setTable(new GroupSymbol("tempTable"));
    create.setOn("source");
    Table t = new Table();
    t.setName("tempTable");
    t.setUUID("tid:0");
    Column c = new Column();
    c.setName("x");
    c.setUUID("tid:0");
    Datatype string = SystemMetadata.getInstance().getRuntimeTypeMap().get("string");
    c.setDatatype(string, true, 0);
    t.addColumn(c);
    c = new Column();
    c.setName("y");
    c.setUUID("tid:0");
    Datatype decimal = SystemMetadata.getInstance().getRuntimeTypeMap().get("decimal");
    c.setDatatype(decimal, true, 0);
    t.addColumn(c);
    t.setCardinality(10000);
    create.setTableMetadata(t);
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("create foreign temporary table tempTable (x string, y decimal) options (cardinality 10000) on source", "CREATE FOREIGN TEMPORARY TABLE tempTable (\n	x string,\n	y bigdecimal\n) OPTIONS (CARDINALITY 10000) ON 'source'", create);
}
Also used : Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) Create(org.teiid.query.sql.lang.Create) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Datatype(org.teiid.metadata.Datatype) Test(org.junit.Test)

Example 75 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestLimitParsing method testLimitWithReferences3.

@Test
public void testLimitWithReferences3() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(new Reference(0), new Reference(1)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit ?,?", "SELECT * FROM a LIMIT ?, ?", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Reference(org.teiid.query.sql.symbol.Reference) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Aggregations

GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)299 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)146 Test (org.junit.Test)108 ArrayList (java.util.ArrayList)92 MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)59 Expression (org.teiid.query.sql.symbol.Expression)52 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)50 Constant (org.teiid.query.sql.symbol.Constant)48 List (java.util.List)43 HashSet (java.util.HashSet)32 Query (org.teiid.query.sql.lang.Query)31 From (org.teiid.query.sql.lang.From)29 SymbolMap (org.teiid.query.sql.util.SymbolMap)29 Select (org.teiid.query.sql.lang.Select)26 Criteria (org.teiid.query.sql.lang.Criteria)22 TempMetadataID (org.teiid.query.metadata.TempMetadataID)21 LinkedList (java.util.LinkedList)20 Command (org.teiid.query.sql.lang.Command)20 Set (java.util.Set)17 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)17