예제 #1
0
        public async Task <IPhysicalOperator <RowHolder> > BuildStatement(Sql.sqlStatement statement, ITransaction tran, IPhysicalOperator <RowHolder> source, InputStringNormalizer stringNormalizer)
        {
            if (statement.Joins.Any())
            {
                IPhysicalOperator <RowHolder> currJoinSource = source;
                for (int i = 0; i < statement.Joins.Length; i++)
                {
                    if (!statement.Joins[i].Item2.IsInner)
                    {
                        throw new NotSupportedException("Only inner join is supported at this point.");
                    }

                    MetadataTable joinRightTable = await this.metadataManager.GetTableManager().GetByName(statement.Joins[i].Item1, tran).ConfigureAwait(false);

                    PhyOpScan scanOpRight = new PhyOpScan(joinRightTable.Collection, tran, joinRightTable.Columns, joinRightTable.TableName);

                    Func <RowHolder, bool> filter = (_) => true;
                    if (FSharpOption <Sql.where> .get_IsSome(statement.Joins[i].Item3))
                    {
                        filter = FilterStatementBuilder.EvalWhere(
                            statement.Joins[i].Item3.Value,
                            QueryProcessingAccessors.MergeColumns(currJoinSource.GetOutputColumns(), scanOpRight.GetOutputColumns()),
                            stringNormalizer);
                    }

                    currJoinSource = new PhyOpLoopInnerJoin(currJoinSource, scanOpRight, filter);
                }

                return(currJoinSource);
            }
            else
            {
                return(source);
            }
        }
예제 #2
0
 public Task <IPhysicalOperator <RowHolder> > BuildStatement(Sql.sqlStatement statement, ITransaction tran, IPhysicalOperator <RowHolder> source, InputStringNormalizer inputStringNormalizer)
 {
     if (FSharpOption <Sql.where> .get_IsSome(statement.Where))
     {
         Sql.where whereStatement = statement.Where.Value;
         IPhysicalOperator <RowHolder> filterOp = new PhyOpFilter(source, FilterStatementBuilder.EvalWhere(whereStatement, source.GetOutputColumns(), inputStringNormalizer));
         return(Task.FromResult(filterOp));
     }
     else
     {
         return(Task.FromResult(source));
     }
 }