org.teiid.query.sql.lang.Query.setFrom()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(465)

本文整理了Java中org.teiid.query.sql.lang.Query.setFrom方法的一些代码示例,展示了Query.setFrom的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setFrom方法的具体详情如下:
包路径:org.teiid.query.sql.lang.Query
类名称:Query
方法名:setFrom

Query.setFrom介绍

[英]Set the from clause for the query.
[中]为查询设置from子句。

代码示例

代码示例来源:origin: org.teiid/teiid-engine

public static Query createMatViewQuery(Object matMetadataId, String matTableName, List<? extends Expression> select, boolean isGlobal) {
  Query query = new Query();
  query.setSelect(new Select(select));
  GroupSymbol gs = new GroupSymbol(matTableName);
  gs.setGlobalTable(isGlobal);
  gs.setMetadataID(matMetadataId);
  query.setFrom(new From(Arrays.asList(new UnaryFromClause(gs))));
  return query;
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

static Query wrapQuery(FromClause fromClause, String groupName) {
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol(groupName));
  Query query = new Query();
  query.setSelect(select);
  From from = new From();
  from.addClause(fromClause);
  query.setFrom(from);        
  return query;
}

代码示例来源:origin: teiid/teiid

@Test public void testLimitWithOffset() {
  Query query = new Query();
  Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
  From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
  query.setSelect(select);
  query.setFrom(from);
  query.setLimit(new Limit(new Constant(new Integer(50)), new Constant(new Integer(100))));
  helpTest(query, "SELECT * FROM a LIMIT 50, 100"); //$NON-NLS-1$ 
}

代码示例来源:origin: org.teiid/teiid-olingo

public QueryCommand buildRootSubQuery(String element, DocumentNode resource) {
    Select s1 = new Select();
    s1.addSymbol(new ElementSymbol(element, resource.getGroupSymbol())); 
    From f1 = new From();
    f1.addGroup(resource.getGroupSymbol());
    Query q1 = new Query();
    q1.setSelect(s1);
    q1.setFrom(f1);    
    q1.setCriteria(resource.getCriteria());  
    return q1;
  }
}

代码示例来源:origin: teiid/teiid

@Test public void testLimit() {
  Query query = new Query();
  Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
  From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
  query.setSelect(select);
  query.setFrom(from);
  query.setLimit(new Limit(null, new Constant(new Integer(100))));
  helpTest("Select * from a limit 100", "SELECT * FROM a LIMIT 100", query); //$NON-NLS-1$ //$NON-NLS-2$
}

代码示例来源:origin: teiid/teiid

@Test public void testLimitWithReferences1() {
  Query query = new Query();
  Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
  From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
  query.setSelect(select);
  query.setFrom(from);
  query.setLimit(new Limit(new Reference(0), new Constant(new Integer(100))));
  helpTest("Select * from a limit ?,100", "SELECT * FROM a LIMIT ?, 100", query); //$NON-NLS-1$ //$NON-NLS-2$
}

代码示例来源:origin: teiid/teiid

@Test public void testObjectTable1() throws Exception {
  Query query = new Query();
  query.setSelect(new Select(Arrays.asList(new MultipleElementSymbol())));
  ObjectTable objectTable = new ObjectTable();
  objectTable.setRowScript("y");
  objectTable.setPassing(Arrays.asList(new DerivedColumn("y", new ElementSymbol("e1"))));
  objectTable.setColumns(Arrays.asList(new ObjectTable.ObjectColumn("z", "time", "now()", null)));
  objectTable.setName("x");
  query.setFrom(new From(Arrays.asList(objectTable)));
  helpTest("select * from objecttable('y' passing e1 as y columns z time 'now()') as x", "SELECT * FROM OBJECTTABLE('y' PASSING e1 AS y COLUMNS z time 'now()') AS x", query);
}

代码示例来源:origin: teiid/teiid

@Test public void testNestedTable() throws Exception {
  String sql = "SELECT * from TABLE(exec foo()) as x"; //$NON-NLS-1$
  Query query = new Query();
  query.setSelect(new Select(Arrays.asList(new MultipleElementSymbol())));
  StoredProcedure sp = new StoredProcedure();
  sp.setProcedureName("foo");
  SubqueryFromClause sfc = new SubqueryFromClause("x", sp);
  sfc.setLateral(true);
  query.setFrom(new From(Arrays.asList(sfc)));
  helpTest(sql, "SELECT * FROM LATERAL(EXEC foo()) AS x", query);
}

代码示例来源:origin: teiid/teiid

private Query createTestQuery(String group) {
  GroupSymbol g = new GroupSymbol(group);
  From from = new From();
  from.addGroup(g);
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol());
  
  Query query1 = new Query();
  query1.setSelect(select);
  query1.setFrom(from);
  return query1;
}

代码示例来源:origin: teiid/teiid

public Query createBaseQuery() throws Exception {
  Query query = new Query();
  
  Select select = new Select();
  select.addSymbol(getElementSymbol(1,1));
  query.setSelect(select);
  
  From from = new From();
  from.addGroup(getPhysicalGroup(1));
  query.setFrom(from);
  
  return query;                
}

代码示例来源:origin: teiid/teiid

public static final Query sample2() { 
  Query q1 = new Query();
  Select select = new Select();
  select.addSymbol(new ElementSymbol("xml"));        //$NON-NLS-1$
  q1.setSelect(select);        
  
  From from = new From();
  from.addGroup(new GroupSymbol("xmltest.doc1")); //$NON-NLS-1$
  q1.setFrom(from);
  return q1;    
}

代码示例来源:origin: teiid/teiid

@Test public void testFetchFirstRow() {
  Query query = new Query();
  Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
  From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
  query.setSelect(select);
  query.setFrom(from);
  query.setLimit(new Limit(null, new Constant(1)));
  helpTest("Select * from a fetch first row only", "SELECT * FROM a LIMIT 1", query); //$NON-NLS-1$ //$NON-NLS-2$
}

代码示例来源:origin: teiid/teiid

@Test public void testFetchFirst() {
  Query query = new Query();
  Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
  From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
  query.setSelect(select);
  query.setFrom(from);
  query.setLimit(new Limit(null, new Constant(2)));
  helpTest("Select * from a fetch first 2 rows only", "SELECT * FROM a LIMIT 2", query); //$NON-NLS-1$ //$NON-NLS-2$
}

代码示例来源:origin: teiid/teiid

@Test public void testQuery1() {
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol());
  From from = new From();
  from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  
  helpTest(query, "SELECT * FROM m.g");		     //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testCommandStatement1() {
  Query q1 = new Query();
  Select select = new Select();
  select.addSymbol(new ElementSymbol("x"));        //$NON-NLS-1$
  q1.setSelect(select);        
  From from = new From();
  from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
  q1.setFrom(from);
      
  CommandStatement cmdStmt =    new CommandStatement(q1);
  helpTest(cmdStmt, "SELECT x FROM g;"); //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testExistsCriteria1() {
  
  Select s1 = new Select();
  s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  From f1 = new From();
  f1.addGroup(new GroupSymbol("m.g1"));        //$NON-NLS-1$
  Query q1 = new Query();
  q1.setSelect(s1);
  q1.setFrom(f1);
  ExistsCriteria ec = new ExistsCriteria(q1);
  helpTest(ec, "EXISTS (SELECT e1 FROM m.g1)");             //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testScalarSubquery() {
  
  Select s1 = new Select();
  s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  From f1 = new From();
  f1.addGroup(new GroupSymbol("m.g1"));        //$NON-NLS-1$
  Query q1 = new Query();
  q1.setSelect(s1);
  q1.setFrom(f1);
  ScalarSubquery obj = new ScalarSubquery(q1);
  helpTest(obj, "(SELECT e1 FROM m.g1)");             //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testOptionalSubqueryFromClause1() {
  Select s1 = new Select();
  s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  From f1 = new From();
  f1.addGroup(new GroupSymbol("m.g1"));        //$NON-NLS-1$
  Query q1 = new Query();
  q1.setSelect(s1);
  q1.setFrom(f1);
  SubqueryFromClause sfc = new SubqueryFromClause("temp", q1); //$NON-NLS-1$
  sfc.setOptional(true);
  helpTest(sfc, "/*+ optional */ (SELECT e1 FROM m.g1) AS temp");             //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testCommandStatement1a() {
  Query q1 = new Query();
  Select select = new Select();
  select.addSymbol(new ElementSymbol("x"));        //$NON-NLS-1$
  q1.setSelect(select);        
  From from = new From();
  from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
  q1.setFrom(from);
      
  CommandStatement cmdStmt =    new CommandStatement(q1);
  cmdStmt.setReturnable(false);
  helpTest(cmdStmt, "SELECT x FROM g WITHOUT RETURN;"); //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testSubqueryCompareCriteria2() {
  
  Select s1 = new Select();
  s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  From f1 = new From();
  f1.addGroup(new GroupSymbol("m.g1"));        //$NON-NLS-1$
  Query q1 = new Query();
  q1.setSelect(s1);
  q1.setFrom(f1);
  ElementSymbol expr = new ElementSymbol("e2"); //$NON-NLS-1$
  SubqueryCompareCriteria scc = new SubqueryCompareCriteria(expr, q1, SubqueryCompareCriteria.LE, SubqueryCompareCriteria.SOME);
  helpTest(scc, "e2 <= SOME (SELECT e1 FROM m.g1)");             //$NON-NLS-1$
}

相关文章