public virtual void Execute(SelectStatement selectStatement) { // Validate top level query specifications foreach (QuerySpecification qs in selectStatement.EnumerateQuerySpecifications()) { ValidateQuerySpecification(qs); } // Validate Order By OrderByClause orderby = selectStatement.FindDescendant<OrderByClause>(); if (orderby != null) { // **** TODO } }
public void Execute(SelectStatement selectStatement) { NormalizeSelectStatement(selectStatement); }
public void NormalizeSelectStatement(SelectStatement selectStatement) { NormalizeQueryExpression(selectStatement.QueryExpression); }
protected void ResolveSelectStatement(SelectStatement selectStatement, int depth) { // The SqlParser build the parsing tree and tags many nodes with TableReference and ColumnReference objects. // At this point these references only contain information directly available in the query, but names are // not verified against the database schema. // A query consists of a set of query specifications combined using set operators (UNION, EXCEPT etc.) // Each query specification has a FROM clause with a complex table expression. A table expression is a // set of table sources combined with join operators. A table source can be any of the following four: // a table (or view), a table-valued function, a table-valued variable or a subquery. // The WHERE clause main contain additional semi-join criteria which contain subqueries. // Steps of name resolution: // 1. Identify all query specifications and execute name resolution on each of them // 2. For each query specification, substitute default values if null is found // 3. Collect column descriptions from table sources // 4. Resolve column aliases // 5. Resolve table aliases // 6. Assign default column aliases SubstituteFunctionDefaults(selectStatement); ResolveFunctionReferences(selectStatement); var qe = selectStatement.QueryExpression; ResolveQueryExpression(qe, depth); var firstqs = qe.FindDescendant<QuerySpecification>(); var orderby = selectStatement.OrderByClause; ResolveOrderByClause(orderby, firstqs); }
/// <summary> /// Executes the name resolution over a query /// </summary> /// <param name="selectStatement"></param> public void Execute(SelectStatement selectStatement) { ResolveSelectStatement(selectStatement, 0); }
private void GetSearchCondition(string query, out SelectStatement select, out SearchCondition where) { var p = new SqlParser(); select = (SelectStatement)p.Execute(new SelectStatement(), query); where = select.FindDescendantRecursive<WhereClause>().FindDescendant<SearchCondition>(); }
private void CopyMembers(SelectStatement old) { }
public SelectStatement(SelectStatement old) : base(old) { CopyMembers(old); }
private void InitializeMembers(StreamingContext context) { this.syncRoot = new object(); this.context = null; this.scheduler = null; this.queryFactoryTypeName = null; this.queryFactory = new Lazy<QueryFactory>(() => (QueryFactory)Activator.CreateInstance(Type.GetType(queryFactoryTypeName)), false); this.federationReference = new EntityProperty<Federation>(); this.queryString = null; this.defaultDataset = null; this.temporaryDataset = null; this.codeDataset = null; this.customDatasets = new List<DatasetBase>(); /*this.databaseVersionName = null; this.defaultDatasetName = null; this.defaultSchemaName = null;*/ this.executionMode = ExecutionMode.SingleServer; this.isCanceled = false; this.cancelableTasks = new Dictionary<string, ICancelableTask>(); this.assignedServerInstanceReference = new EntityProperty<ServerInstance>(); this.interpretedQueryString = null; this.selectStatement = null; this.temporaryDatabaseInstanceReference = new EntityProperty<DatabaseInstance>(); this.temporaryTables = new ConcurrentDictionary<string, Table>(SchemaManager.Comparer); this.temporaryViews = new ConcurrentDictionary<string, View>(SchemaManager.Comparer); this.codeDatabaseInstanceReference = new EntityProperty<DatabaseInstance>(); }
/// <summary> /// Parses the query /// </summary> protected void Parse(bool forceReinitialize) { // Reparse only if needed if (selectStatement == null || forceReinitialize) { var parser = queryFactory.Value.CreateParser(); selectStatement = (SelectStatement)parser.Execute(queryString); } }