Beispiel #1
0
        // translate transform calls on tuple into a function call
        AstValue PostFixTranTup(AstValue value, AstTransformer tran)
        {
            Types.CheckTypeMatch(DataTypes.Row, value.DataType);
            if (tran == null)
            {
                return(value);
            }
            var args = Args(value, tran.Elements);

            return(FunCall(FindFunc(SymNames.TransTuple), tran.DataType, args, args.Length - 1));
        }
Beispiel #2
0
 // UPDATE rel .where(pred) .{ sets }
 public AstStatement UpdateWhere(AstValue relvar, AstValue wherearg, AstTransformer tran)
 {
     var where = (wherearg != null) ? (wherearg as AstWhere).Arguments[0] : null;
     // null means delete
     if (tran == null)
     {
         return(FunCall(FindFunc(SymNames.UpdateTransform), DataTypes.Void,
                        Args(relvar, Args(where)), 0));
     }
     if (tran.DataType.Heading != relvar.DataType.Heading)
     {
         Parser.ParseError("field mismatch");
     }
     return(FunCall(FindFunc(SymNames.UpdateTransform), DataTypes.Void,
                    Args(relvar, Args(where, tran.Elements)), tran.Elements.Length));
 }
Beispiel #3
0
        // translate transform call and possible order into a function call
        // note that tran may be empty, and this has meaning!
        AstValue PostFixTranRel(AstValue value, AstTransformer tran, AstOrderer order)
        {
            Types.CheckTypeMatch(DataTypes.Table, value.DataType);
            var args = new List <AstNode> {
                value
            };

            if (order != null)
            {
                args.AddRange(order.Elements);
            }
            if (tran != null)
            {
                args.AddRange(tran.Elements);
            }
            if (tran != null)
            {
                // transformation, possibly ordered
                // Decide which processor to use depending on level of elements
                var opname = tran.Elements.Any(e => e is AstExtend && (e as AstExtend).HasWin) ? SymNames.TransWin
          : (order != null) ? SymNames.TransOrd
          : tran.Elements.Any(e => e is AstExtend && (e as AstExtend).Accums > 0) ? SymNames.TransAgg
          : tran.Elements.Any(e => e is AstExtend) ? SymNames.Transform
          : tran.Elements.All(e => e is AstRename) && tran.Elements.Length == value.DataType.Heading.Degree ? SymNames.Rename
          : SymNames.Project;
                return(FunCall(FindFunc(opname), tran.DataType, args.ToArray(), args.Count - 1));
            }
            else if (order != null)
            {
                // just a sort, convenient way to include all fields in heading
                args.AddRange(Allbut(value.DataType.Heading, new AstField[0]));
                return(FunCall(FindFunc(SymNames.TransOrd), value.DataType, args.ToArray(), args.Count - 1));
            }
            else
            {
                return(value); // nothing do to
            }
        }
Beispiel #4
0
 // Row by Transform
 public AstValue Row(AstTransformer transformer)
 {
     return(new AstTabCall {
         Func = FindFunc(SymNames.RowE), DataType = Types.Tupof(transformer.DataType), Arguments = transformer.Elements,
     });
 }