本文整理了Java中com.facebook.presto.sql.tree.QuerySpecification.getFrom
方法的一些代码示例,展示了QuerySpecification.getFrom
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QuerySpecification.getFrom
方法的具体详情如下:
包路径:com.facebook.presto.sql.tree.QuerySpecification
类名称:QuerySpecification
方法名:getFrom
暂无
代码示例来源:origin: prestodb/presto
private Scope analyzeFrom(QuerySpecification node, Optional<Scope> scope)
{
if (node.getFrom().isPresent()) {
return process(node.getFrom().get(), scope);
}
return createScope(scope);
}
代码示例来源:origin: prestodb/presto
private PlanBuilder planFrom(QuerySpecification node)
{
RelationPlan relationPlan;
if (node.getFrom().isPresent()) {
relationPlan = new RelationPlanner(analysis, symbolAllocator, idAllocator, lambdaDeclarationToSymbolMap, metadata, session)
.process(node.getFrom().get(), null);
}
else {
relationPlan = planImplicitTable();
}
return planBuilderFor(relationPlan);
}
代码示例来源:origin: prestodb/presto
if (node.getFrom().isPresent()) {
append(indent, "FROM");
builder.append('\n');
append(indent, " ");
process(node.getFrom().get(), indent);
代码示例来源:origin: prestodb/presto
@Override
protected R visitQuerySpecification(QuerySpecification node, C context)
{
process(node.getSelect(), context);
if (node.getFrom().isPresent()) {
process(node.getFrom().get(), context);
}
if (node.getWhere().isPresent()) {
process(node.getWhere().get(), context);
}
if (node.getGroupBy().isPresent()) {
process(node.getGroupBy().get(), context);
}
if (node.getHaving().isPresent()) {
process(node.getHaving().get(), context);
}
if (node.getOrderBy().isPresent()) {
process(node.getOrderBy().get(), context);
}
return null;
}
代码示例来源:origin: prestodb/presto
@Override
protected Node visitShowStats(ShowStats node, Void context)
{
checkState(queryExplainer.isPresent(), "Query explainer must be provided for SHOW STATS SELECT");
if (node.getRelation() instanceof TableSubquery) {
Query query = ((TableSubquery) node.getRelation()).getQuery();
QuerySpecification specification = (QuerySpecification) query.getQueryBody();
Plan plan = queryExplainer.get().getLogicalPlan(session, new Query(Optional.empty(), specification, Optional.empty(), Optional.empty()), parameters, warningCollector);
validateShowStatsSubquery(node, query, specification, plan);
Table table = (Table) specification.getFrom().get();
Constraint<ColumnHandle> constraint = getConstraint(plan);
return rewriteShowStats(node, table, constraint);
}
else if (node.getRelation() instanceof Table) {
Table table = (Table) node.getRelation();
return rewriteShowStats(node, table, Constraint.alwaysTrue());
}
else {
throw new IllegalArgumentException("Expected either TableSubquery or Table as relation");
}
}
代码示例来源:origin: prestodb/presto
innerQuery = new QuerySpecification(
querySpecification.getSelect(),
querySpecification.getFrom(),
querySpecification.getWhere(),
querySpecification.getGroupBy(),
代码示例来源:origin: prestodb/presto
private void validateShowStatsSubquery(ShowStats node, Query query, QuerySpecification querySpecification, Plan plan)
{
// The following properties of SELECT subquery are required:
// - only one relation in FROM
// - only predicates that can be pushed down can be in the where clause
// - no group by
// - no having
// - no set quantifier
Optional<FilterNode> filterNode = searchFrom(plan.getRoot())
.where(FilterNode.class::isInstance)
.findSingle();
check(!filterNode.isPresent(), node, "Only predicates that can be pushed down are supported in the SHOW STATS WHERE clause");
check(querySpecification.getFrom().isPresent(), node, "There must be exactly one table in query passed to SHOW STATS SELECT clause");
check(querySpecification.getFrom().get() instanceof Table, node, "There must be exactly one table in query passed to SHOW STATS SELECT clause");
check(!query.getWith().isPresent(), node, "WITH is not supported by SHOW STATS SELECT clause");
check(!querySpecification.getOrderBy().isPresent(), node, "ORDER BY is not supported in SHOW STATS SELECT clause");
check(!querySpecification.getLimit().isPresent(), node, "LIMIT is not supported by SHOW STATS SELECT clause");
check(!querySpecification.getHaving().isPresent(), node, "HAVING is not supported in SHOW STATS SELECT clause");
check(!querySpecification.getGroupBy().isPresent(), node, "GROUP BY is not supported in SHOW STATS SELECT clause");
check(!querySpecification.getSelect().isDistinct(), node, "DISTINCT is not supported by SHOW STATS SELECT clause");
List<SelectItem> selectItems = querySpecification.getSelect().getSelectItems();
check(selectItems.size() == 1 && selectItems.get(0) instanceof AllColumns, node, "Only SELECT * is supported in SHOW STATS SELECT clause");
}
代码示例来源:origin: prestodb/presto
if (node.getFrom().isPresent()) {
print(indentLevel, "From");
process(node.getFrom().get(), indentLevel + 1);
代码示例来源:origin: prestodb/presto
throw new SemanticException(MISSING_TABLE, item, "Table '%s' not found", starPrefix.get());
if (!node.getFrom().isPresent()) {
throw new SemanticException(WILDCARD_WITHOUT_FROM, item, "SELECT * not allowed in queries without FROM clause");
代码示例来源:origin: prestodb/presto
getLocation(context),
query.getSelect(),
query.getFrom(),
query.getWhere(),
query.getGroupBy(),
代码示例来源:origin: rakam-io/rakam
@Override
protected Void visitQuerySpecification(QuerySpecification node, Integer indent) {
process(node.getSelect(), indent);
if (node.getFrom().isPresent()) {
append(indent, "FROM");
builder.append('\n');
append(indent, " ");
process(node.getFrom().get(), indent);
}
builder.append('\n');
if (node.getWhere().isPresent()) {
append(indent, "WHERE " + formatExpression(node.getWhere().get(), tableNameMapper, columnNameMapper, queryWithTables, escapeIdentifier))
.append('\n');
}
if (node.getGroupBy().isPresent()) {
append(indent, "GROUP BY " + (node.getGroupBy().get().isDistinct() ? " DISTINCT " : "") + formatGroupBy(node.getGroupBy().get().getGroupingElements())).append('\n');
}
if (node.getHaving().isPresent()) {
append(indent, "HAVING " + formatExpression(node.getHaving().get(), tableNameMapper, columnNameMapper, queryWithTables, escapeIdentifier))
.append('\n');
}
if (node.getOrderBy().isPresent()) {
process(node.getOrderBy().get(), indent);
}
if (node.getLimit().isPresent()) {
append(indent, "LIMIT " + node.getLimit().get())
.append('\n');
}
return null;
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
private RelationType analyzeFrom(QuerySpecification node, AnalysisContext context)
{
RelationType fromDescriptor = new RelationType();
if (node.getFrom().isPresent()) {
fromDescriptor = process(node.getFrom().get(), context);
}
return fromDescriptor;
}
代码示例来源:origin: stackoverflow.com
public class PrestoParserTest {
public static void main(String[] args) {
SqlParser parser = new SqlParser();
String sql = "select * from xyz where x=y group by x order by y limit 10";
Query query = (Query)parser.createStatement(sql);
QuerySpecification body = (QuerySpecification)query.getQueryBody();
Select select = body.getSelect();
System.out.println("Columns = " + select.getSelectItems());
System.out.println("From = " + body.getFrom().get());
Optional<Expression> where = body.getWhere();
System.out.println("Where = " + where.get());
System.out.println("Group by = " + body.getGroupBy());
System.out.println("Order by = " + body.getOrderBy());
System.out.println("Limit = " + body.getLimit().get());
}
}
代码示例来源:origin: com.facebook.presto/presto-parser
@Override
protected R visitQuerySpecification(QuerySpecification node, C context)
{
process(node.getSelect(), context);
if (node.getFrom().isPresent()) {
process(node.getFrom().get(), context);
}
if (node.getWhere().isPresent()) {
process(node.getWhere().get(), context);
}
if (node.getGroupBy().isPresent()) {
process(node.getGroupBy().get(), context);
}
if (node.getHaving().isPresent()) {
process(node.getHaving().get(), context);
}
if (node.getOrderBy().isPresent()) {
process(node.getOrderBy().get(), context);
}
return null;
}
代码示例来源:origin: vqtran/EchoQuery
if (node.getFrom().isPresent()) {
append(indent, "FROM");
builder.append('\n');
append(indent, " ");
process(node.getFrom().get(), indent);
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
private PlanBuilder planFrom(QuerySpecification node)
{
RelationPlan relationPlan;
if (node.getFrom().isPresent()) {
relationPlan = new RelationPlanner(analysis, symbolAllocator, idAllocator, metadata, session)
.process(node.getFrom().get(), null);
}
else {
relationPlan = planImplicitTable();
}
TranslationMap translations = new TranslationMap(relationPlan, analysis);
// Make field->symbol mapping from underlying relation plan available for translations
// This makes it possible to rewrite FieldOrExpressions that reference fields from the FROM clause directly
translations.setFieldMappings(relationPlan.getOutputSymbols());
return new PlanBuilder(translations, relationPlan.getRoot(), relationPlan.getSampleWeight());
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-parser
if (node.getFrom().isPresent()) {
append(indent, "FROM");
builder.append('\n');
append(indent, " ");
process(node.getFrom().get(), indent);
代码示例来源:origin: com.facebook.presto/presto-parser
if (node.getFrom().isPresent()) {
append(indent, "FROM");
builder.append('\n');
append(indent, " ");
process(node.getFrom().get(), indent);
代码示例来源:origin: uk.co.nichesolutions.presto/presto-parser
@Override
protected R visitQuerySpecification(QuerySpecification node, C context)
{
process(node.getSelect(), context);
if (node.getFrom().isPresent()) {
process(node.getFrom().get(), context);
}
if (node.getWhere().isPresent()) {
process(node.getWhere().get(), context);
}
if (node.getGroupBy().isPresent()) {
for (GroupingElement groupingElement : node.getGroupBy().get().getGroupingElements()) {
process(groupingElement, context);
}
}
if (node.getHaving().isPresent()) {
process(node.getHaving().get(), context);
}
for (SortItem sortItem : node.getOrderBy()) {
process(sortItem, context);
}
return null;
}
代码示例来源:origin: Anchormen/sql4es
if(!(queryBody instanceof QuerySpecification)) throw new SQLException("Statement does not contain expected query specifiction");
QuerySpecification querySpec = (QuerySpecification)queryBody;
if(!querySpec.getFrom().isPresent()) throw new SQLException("Add atleast one INDEX to the query to create the view from");
List<QuerySource> relations = new RelationParser().process(querySpec.getFrom().get(), null);
String[] indices = new String[relations.size()];
for(int i=0; i<relations.size(); i++) indices[i] = relations.get(i).getSource();
内容来源于网络,如有侵权,请联系作者删除!