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

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

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

Query.getSelect介绍

[英]Get the select clause for the query.
[中]获取查询的select子句。

代码示例

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

public void setShouldEvaluateExpressions(boolean shouldEvaluate) {
  if (shouldEvaluate && projection != null) {
    //restore the original as we'll minimize each time
    ((Query)this.command).getSelect().setSymbols(this.originalSelect);
    this.projection = null;
  }
  this.shouldEvaluate = shouldEvaluate;
}

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

private void correctProjectedTypes(List actualSymbolTypes, Query query) {
  
  List symbols = query.getSelect().getProjectedSymbols();
  
  List newSymbols = SetQuery.getTypedProjectedSymbols(symbols, actualSymbolTypes, this.metadata);
  
  query.getSelect().setSymbols(newSymbols);
}

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

private void correctProjectedTypes(List actualSymbolTypes, Query query) {
  
  List symbols = query.getSelect().getProjectedSymbols();
  
  List newSymbols = SetQuery.getTypedProjectedSymbols(symbols, actualSymbolTypes, this.metadata);
  
  query.getSelect().setSymbols(newSymbols);
}

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

public boolean hasAggregates() {
  return getGroupBy() != null 
  || getHaving() != null 
  || !AggregateSymbolCollectorVisitor.getAggregates(getSelect(), false).isEmpty();
}

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

public boolean hasAggregates() {
  return getGroupBy() != null 
  || getHaving() != null 
  || !AggregateSymbolCollectorVisitor.getAggregates(getSelect(), false).isEmpty();
}

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

/**
 * Validates SELECT INTO queries.
 * @param query
 * @since 4.2
 */
protected void validateSelectInto(Query query) {
  List<Expression> symbols = query.getSelect().getProjectedSymbols();
  GroupSymbol intoGroup = query.getInto().getGroup();
  validateInto(query, symbols, intoGroup);
}

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

/**
 * Validates SELECT INTO queries.
 * @param query
 * @since 4.2
 */
protected void validateSelectInto(Query query) {
  List<Expression> symbols = query.getSelect().getProjectedSymbols();
  GroupSymbol intoGroup = query.getInto().getGroup();
  validateInto(query, symbols, intoGroup);
}

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

/**
 * Validates SELECT INTO queries.
 * @param query
 * @since 4.2
 */
protected void validateSelectInto(Query query) {
  List<Expression> symbols = query.getSelect().getProjectedSymbols();
  GroupSymbol intoGroup = query.getInto().getGroup();
  validateInto(query, symbols, intoGroup);
}

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

public static Query rowConstructor(List<Expression> select) {
  Query query = new Query();
  query.setSelect(new Select());
  query.getSelect().addSymbols(select);
  query.setRowConstructor(true);
  return query;
}

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

@Test public void testAliasedElementWithVDB() {
  Query resolvedQuery = (Query) helpResolve("SELECT example1.pm1.g1.e1 AS x FROM pm1.g1"); //$NON-NLS-1$
  helpCheckSelect(resolvedQuery, new String[] { "x" }); //$NON-NLS-1$
  helpCheckElements(resolvedQuery.getSelect(),
    new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
    new String[] { "pm1.g1.e1" } ); //$NON-NLS-1$
}

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

@Test public void testSelectStarFromAliasedGroup() {
  Query resolvedQuery = (Query) helpResolve("SELECT * FROM pm1.g1 as x"); //$NON-NLS-1$
  helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
  helpCheckElements(resolvedQuery.getSelect(),
    new String[] { "x.e1", "x.e2", "x.e3", "x.e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}

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

@Test public void testSelectStarWhereSomeElementsAreNotSelectable() {
  Query resolvedQuery = (Query) helpResolve("SELECT * FROM pm1.g4"); //$NON-NLS-1$
  helpCheckFrom(resolvedQuery, new String[] { "pm1.g4" }); //$NON-NLS-1$
  helpCheckElements(resolvedQuery.getSelect(),
    new String[] { "pm1.g4.e1", "pm1.g4.e3" }, //$NON-NLS-1$ //$NON-NLS-2$
    new String[] { "pm1.g4.e1", "pm1.g4.e3" } ); //$NON-NLS-1$ //$NON-NLS-2$
}

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

@Test public void testMultipleIdenticalElements() { 
  Query resolvedQuery = (Query) helpResolve("SELECT e1, e1 FROM pm1.g1"); //$NON-NLS-1$
  helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
  helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
  helpCheckElements(resolvedQuery.getSelect(), 
    new String[] { "pm1.g1.e1", "pm1.g1.e1" },  //$NON-NLS-1$ //$NON-NLS-2$
    new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
}

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

@Test public void testMultipleIdenticalElements2() { 
  Query resolvedQuery = (Query) helpResolve("SELECT e1, pm1.g1.e1 FROM pm1.g1"); //$NON-NLS-1$
  helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
  helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
  helpCheckElements(resolvedQuery.getSelect(), 
    new String[] { "pm1.g1.e1", "pm1.g1.e1" },  //$NON-NLS-1$ //$NON-NLS-2$
    new String[] { "pm1.g1.e1", "pm1.g1.e1" }); //$NON-NLS-1$ //$NON-NLS-2$
}

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

@Test public void testDifferentElementsSameName() { 
  Query resolvedQuery = (Query) helpResolve("SELECT e1 as x, e2 as x FROM pm1.g2"); //$NON-NLS-1$
  helpCheckFrom(resolvedQuery, new String[] { "pm1.g2" }); //$NON-NLS-1$
  helpCheckSelect(resolvedQuery, new String[] { "x", "x" }); //$NON-NLS-1$ //$NON-NLS-2$
  helpCheckElements(resolvedQuery.getSelect(), 
    new String[] { "pm1.g2.e1", "pm1.g2.e2" },  //$NON-NLS-1$ //$NON-NLS-2$
    new String[] { "pm1.g2.e1", "pm1.g2.e2" }); //$NON-NLS-1$ //$NON-NLS-2$
}

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

@Test public void testElementWithVDB() {
  String sql = "SELECT example1.pm1.g1.e1 FROM pm1.g1"; //$NON-NLS-1$
  Query resolvedQuery = (Query) helpResolve(sql);
  helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1" }); //$NON-NLS-1$
  helpCheckElements(resolvedQuery.getSelect(),
    new String[] { "pm1.g1.e1" }, //$NON-NLS-1$
    new String[] { "pm1.g1.e1" } ); //$NON-NLS-1$
  assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}

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

@Test public void testNullConstantInSelect() throws Exception {
  String userSql = "SELECT null as x"; //$NON-NLS-1$
  Query query = (Query)helpParse(userSql);
  
  QueryResolver.resolveCommand(query, RealMetadataFactory.exampleBQTCached());
  
  // Check type of resolved null constant
  Expression symbol = query.getSelect().getSymbols().get(0);
  assertNotNull(symbol.getType());
  assertEquals(DataTypeManager.DefaultDataClasses.STRING, symbol.getType());
}

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

@Test public void testElementSymbolForms() {
  String sql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 AS a, e4 AS b FROM pm1.g1"; //$NON-NLS-1$
  Query resolvedQuery = (Query) helpResolve(sql);
  helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
  helpCheckSelect(resolvedQuery, new String[] { "pm1.g1.e1", "pm1.g1.e2", "a", "b" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  helpCheckElements(resolvedQuery.getSelect(), 
    new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}

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

@Test public void testElementSymbolFormsWithAliasedGroup() {
  String sql = "SELECT x.e1, e2, x.e3 AS a, e4 AS b FROM pm1.g1 AS x"; //$NON-NLS-1$
  Query resolvedQuery = (Query) helpResolve(sql);
  helpCheckFrom(resolvedQuery, new String[] { "pm1.g1" }); //$NON-NLS-1$
  helpCheckSelect(resolvedQuery, new String[] { "x.e1", "x.e2", "a", "b" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  helpCheckElements(resolvedQuery.getSelect(),
    new String[] { "x.e1", "x.e2", "x.e3", "x.e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    new String[] { "pm1.g1.e1", "pm1.g1.e2", "pm1.g1.e3", "pm1.g1.e4" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  assertEquals("Resolved string form was incorrect ", sql, resolvedQuery.toString()); //$NON-NLS-1$
}

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

@Test public void testNationCharString() throws Exception {
  Query query = (Query) QueryParser.getQueryParser().parseCommand("SELECT N'blah' FROM m.g"); //$NON-NLS-1$
  Select select = query.getSelect();
  Constant c = (Constant) SymbolMap.getExpression(select.getSymbol(0));
  assertEquals(c, new Constant("blah")); //$NON-NLS-1$
}

相关文章