Search in sources :

Example 21 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestValidator method testInsert5.

// non-null, no-default elements left
@Test
public void testInsert5() throws Exception {
    QueryMetadataInterface metadata = exampleMetadata1();
    // $NON-NLS-1$
    Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group (e1, e2) VALUES ('x', 'y')");
    QueryResolver.resolveCommand(command, metadata);
    // $NON-NLS-1$
    helpRunValidator(command, new String[] { "test.\"group\".e0" }, metadata);
}
Also used : Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 22 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestValidator method testCreateWithNonSortablePrimaryKey.

@Test
public void testCreateWithNonSortablePrimaryKey() {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    Command command = helpResolve("create local temporary table x (column1 string, column2 clob, primary key (column2))", metadata);
    helpRunValidator(command, new String[] { "column2" }, RealMetadataFactory.example1Cached());
}
Also used : Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 23 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestValidator method testValidateInModeler.

@Test
public void testValidateInModeler() throws Exception {
    // SQL is same as pm1.vsp36() in example1
    // $NON-NLS-1$
    String sql = "CREATE VIRTUAL PROCEDURE BEGIN select 1, 2; END";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    Command command = QueryParser.getQueryParser().parseCommand(sql);
    GroupSymbol group = new GroupSymbol("pm1.vsp36");
    QueryResolver.resolveCommand(command, group, Command.TYPE_STORED_PROCEDURE, metadata, true);
    assertEquals(2, command.getResultSetColumns().size());
}
Also used : Command(org.teiid.query.sql.lang.Command) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Example 24 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestValidator method testDefect9917.

@Test
public void testDefect9917() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    String sql = "SELECT lookup('pm1.g1', 'e1a', 'e2', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1";
    Command command = new QueryParser().parseCommand(sql);
    try {
        QueryResolver.resolveCommand(command, metadata);
        // $NON-NLS-1$
        fail("Did not get exception");
    } catch (QueryResolverException e) {
    // expected
    }
    // $NON-NLS-1$
    sql = "SELECT lookup('pm1.g1a', 'e1', 'e2', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1";
    command = new QueryParser().parseCommand(sql);
    try {
        QueryResolver.resolveCommand(command, metadata);
        // $NON-NLS-1$
        fail("Did not get exception");
    } catch (QueryResolverException e) {
    // expected
    }
}
Also used : QueryParser(org.teiid.query.parser.QueryParser) Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) QueryResolverException(org.teiid.api.exception.query.QueryResolverException) Test(org.junit.Test)

Example 25 with Command

use of org.teiid.query.sql.lang.Command in project teiid by teiid.

the class TestValidator method testValidateInsertElements2.

@Test
public void testValidateInsertElements2() throws Exception {
    QueryMetadataInterface metadata = exampleMetadata();
    // $NON-NLS-1$
    Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group2 (e1) VALUES ('y')");
    QueryResolver.resolveCommand(command, metadata);
    helpRunValidator(command, new String[] {}, metadata);
}
Also used : Command(org.teiid.query.sql.lang.Command) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) Test(org.junit.Test)

Aggregations

Command (org.teiid.query.sql.lang.Command)232 Test (org.junit.Test)142 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)90 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)73 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)66 List (java.util.List)64 CommandContext (org.teiid.query.util.CommandContext)38 ArrayList (java.util.ArrayList)37 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)36 BigInteger (java.math.BigInteger)29 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)25 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)21 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)20 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)19 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 LinkedList (java.util.LinkedList)10 QueryParser (org.teiid.query.parser.QueryParser)10 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)10 QueryCommand (org.teiid.query.sql.lang.QueryCommand)10 StoredProcedure (org.teiid.query.sql.lang.StoredProcedure)10