// CreateFunction mocks base method
487064
func (m *MockLambdaAPI) CreateFunction(arg0 *lambda.CreateFunctionInput) (*lambda.FunctionConfiguration, error) {
	ret := m.ctrl.Call(m, "CreateFunction", arg0)
	ret0, _ := ret[0].(*lambda.FunctionConfiguration)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
1083600
func (m *MockVolumeDriver) Create(arg0 *api.VolumeLocator, arg1 *api.Source, arg2 *api.VolumeSpec) (string, error) {
	ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2)
	ret0, _ := ret[0].(string)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
1271908
func createFunctionCursor(t *transpilerState, call *influxql.Call, in cursor, normalize bool) (cursor, error) {
	cur := &functionCursor{
		call:   call,
		parent: in,
	}
	switch call.Name {
	case "count":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("count", &transformations.CountOpSpec{
			AggregateConfig: execute.AggregateConfig{
				Columns: []string{value},
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "min":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("min", &transformations.MinOpSpec{
			SelectorConfig: execute.SelectorConfig{
				Column: value,
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "max":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("max", &transformations.MaxOpSpec{
			SelectorConfig: execute.SelectorConfig{
				Column: value,
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "sum":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("sum", &transformations.SumOpSpec{
			AggregateConfig: execute.AggregateConfig{
				Columns: []string{value},
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "first":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("first", &transformations.FirstOpSpec{
			SelectorConfig: execute.SelectorConfig{
				Column: value,
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "last":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("last", &transformations.LastOpSpec{
			SelectorConfig: execute.SelectorConfig{
				Column: value,
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "mean":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("mean", &transformations.MeanOpSpec{
			AggregateConfig: execute.AggregateConfig{
				Columns: []string{value},
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "median":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.id = t.op("median", &transformations.PercentileOpSpec{
			Percentile:  0.5,
			Compression: 0,
			Method:      "exact_mean",
			AggregateConfig: execute.AggregateConfig{
				Columns: []string{value},
			},
		}, in.ID())
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "percentile":
		if len(call.Args) != 2 {
			return nil, errors.New("percentile function requires two arguments field_key and N")
		}

		fieldName, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}

		var percentile float64
		switch arg := call.Args[1].(type) {
		case *influxql.NumberLiteral:
			percentile = arg.Val / 100.0
		case *influxql.IntegerLiteral:
			percentile = float64(arg.Val) / 100.0
		default:
			return nil, errors.New("argument N must be a float type")
		}

		if percentile < 0 || percentile > 1 {
			return nil, errors.New("argument N must be between 0 and 100")
		}

		cur.id = t.op("percentile", &transformations.PercentileOpSpec{
			Percentile:  percentile,
			Compression: 0,
			Method:      "exact_selector",
			AggregateConfig: execute.AggregateConfig{
				Columns: []string{fieldName},
			},
		}, in.ID())
		cur.value = fieldName
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	default:
		return nil, fmt.Errorf("unimplemented function: %q", call.Name)
	}

	// If we have been told to normalize the time, we do it here.
	if normalize {
		if influxql.IsSelector(call) {
			cur.id = t.op("drop", &transformations.DropOpSpec{
				Columns: []string{execute.DefaultTimeColLabel},
			}, cur.id)
		}
		cur.id = t.op("duplicate", &transformations.DuplicateOpSpec{
			Column: execute.DefaultStartColLabel,
			As:     execute.DefaultTimeColLabel,
		}, cur.id)
	}
	return cur, nil
}
507104
func createFunctionCursor(t *transpilerState, call *influxql.Call, in cursor, normalize bool) (cursor, error) {
	cur := &functionCursor{
		call:   call,
		parent: in,
	}
	switch call.Name {
	case "count", "min", "max", "sum", "first", "last", "mean":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.expr = &ast.PipeExpression{
			Argument: in.Expr(),
			Call: &ast.CallExpression{
				Callee: &ast.Identifier{
					Name: call.Name,
				},
			},
		}
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "median":
		value, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}
		cur.expr = &ast.PipeExpression{
			Argument: in.Expr(),
			Call: &ast.CallExpression{
				Callee: &ast.Identifier{
					Name: "percentile",
				},
				Arguments: []ast.Expression{
					&ast.ObjectExpression{
						Properties: []*ast.Property{
							{
								Key: &ast.Identifier{
									Name: "percentile",
								},
								Value: &ast.FloatLiteral{
									Value: 0.5,
								},
							},
							{
								Key: &ast.Identifier{
									Name: "method",
								},
								Value: &ast.StringLiteral{
									Value: "exact_mean",
								},
							},
						},
					},
				},
			},
		}
		cur.value = value
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	case "percentile":
		if len(call.Args) != 2 {
			return nil, errors.New("percentile function requires two arguments field_key and N")
		}

		fieldName, ok := in.Value(call.Args[0])
		if !ok {
			return nil, fmt.Errorf("undefined variable: %s", call.Args[0])
		}

		var percentile float64
		switch arg := call.Args[1].(type) {
		case *influxql.NumberLiteral:
			percentile = arg.Val / 100.0
		case *influxql.IntegerLiteral:
			percentile = float64(arg.Val) / 100.0
		default:
			return nil, errors.New("argument N must be a float type")
		}

		if percentile < 0 || percentile > 1 {
			return nil, errors.New("argument N must be between 0 and 100")
		}

		args := []*ast.Property{
			{
				Key: &ast.Identifier{
					Name: "percentile",
				},
				Value: &ast.FloatLiteral{
					Value: percentile,
				},
			},
			{
				Key: &ast.Identifier{
					Name: "method",
				},
				Value: &ast.StringLiteral{
					Value: "exact_selector",
				},
			},
		}
		if fieldName != execute.DefaultValueColLabel {
			args = append(args, &ast.Property{
				Key: &ast.Identifier{
					Name: "columns",
				},
				Value: &ast.ArrayExpression{
					Elements: []ast.Expression{
						&ast.StringLiteral{Value: fieldName},
					},
				},
			})
		}
		cur.expr = &ast.PipeExpression{
			Argument: in.Expr(),
			Call: &ast.CallExpression{
				Callee: &ast.Identifier{
					Name: "percentile",
				},
				Arguments: []ast.Expression{
					&ast.ObjectExpression{
						Properties: args,
					},
				},
			},
		}
		cur.value = fieldName
		cur.exclude = map[influxql.Expr]struct{}{call.Args[0]: {}}
	default:
		return nil, fmt.Errorf("unimplemented function: %q", call.Name)
	}

	// If we have been told to normalize the time, we do it here.
	if normalize {
		if influxql.IsSelector(call) {
			cur.expr = &ast.PipeExpression{
				Argument: cur.expr,
				Call: &ast.CallExpression{
					Callee: &ast.Identifier{
						Name: "drop",
					},
					Arguments: []ast.Expression{
						&ast.ObjectExpression{
							Properties: []*ast.Property{{
								Key: &ast.Identifier{
									Name: "columns",
								},
								Value: &ast.ArrayExpression{
									Elements: []ast.Expression{
										&ast.StringLiteral{Value: execute.DefaultTimeColLabel},
									},
								},
							}},
						},
					},
				},
			}
		}
		cur.expr = &ast.PipeExpression{
			Argument: cur.expr,
			Call: &ast.CallExpression{
				Callee: &ast.Identifier{
					Name: "duplicate",
				},
				Arguments: []ast.Expression{
					&ast.ObjectExpression{
						Properties: []*ast.Property{
							{
								Key: &ast.Identifier{
									Name: "column",
								},
								Value: &ast.StringLiteral{
									Value: execute.DefaultStartColLabel,
								},
							},
							{
								Key: &ast.Identifier{
									Name: "as",
								},
								Value: &ast.StringLiteral{
									Value: execute.DefaultTimeColLabel,
								},
							},
						},
					},
				},
			},
		}
	}
	return cur, nil
}
970230
func (service *BaseService) AddFunction(name string, function interface{}, option ...Options) Service {
	service.methodManager.AddFunction(name, function, option...)
	return service
}
988755
func NewFunction(args []Type, result Type) *Function {
	return &Function{
		args:   args,
		result: result,
	}
}
448613
func (m *MockGeneration) Created() int64 {
	ret := m.ctrl.Call(m, "Created")
	ret0, _ := ret[0].(int64)
	return ret0
}
1042070
func (f *MockFunction) Return(v ...interface{}) *MockFunction {
	f.ReturnValues = append(f.ReturnValues, v...)
	return f
}
1232401
func (m *MockLambdaAPI) ListFunctions(arg0 *lambda.ListFunctionsInput) (*lambda.ListFunctionsOutput, error) {
	ret := m.ctrl.Call(m, "ListFunctions", arg0)
	ret0, _ := ret[0].(*lambda.ListFunctionsOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
1056555
func (mm *methodManager) AddFunctions(
	names []string, functions []interface{}, option ...Options) {
	count := len(names)
	if count != len(functions) {
		panic("names and functions must have the same length")
	}
	for i := 0; i < count; i++ {
		mm.AddFunction(names[i], functions[i], option...)
	}
}
839016
func (m *MockServiceAccountInterface) CreateToken(arg0 string, arg1 *v1.TokenRequest) (*v1.TokenRequest, error) {
	ret := m.ctrl.Call(m, "CreateToken", arg0, arg1)
	ret0, _ := ret[0].(*v1.TokenRequest)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
708919
func NewMockBuilderFactory(ctrl *gomock.Controller) *MockBuilderFactory {
	mock := &MockBuilderFactory{ctrl: ctrl}
	mock.recorder = &MockBuilderFactoryMockRecorder{mock}
	return mock
}
1365036
func newFunctionNode(name, prefix string, args []node) node {
	return &functionNode{nodeType: nodeFunction, Prefix: prefix, FuncName: name, Args: args}
}
1247193
func (mr *MockSecretInterfaceMockRecorder) Create(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockSecretInterface)(nil).Create), arg0)
}
1170300
func (m *MockLambdaAPI) DeleteFunctionWithContext(arg0 aws.Context, arg1 *lambda.DeleteFunctionInput, arg2 ...request.Option) (*lambda.DeleteFunctionOutput, error) {
	varargs := []interface{}{arg0, arg1}
	for _, a := range arg2 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "DeleteFunctionWithContext", varargs...)
	ret0, _ := ret[0].(*lambda.DeleteFunctionOutput)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
72620
func (mm *methodManager) AddFunction(
	name string, function interface{}, option ...Options) {
	if name == "" {
		panic("name can't be empty")
	}
	if function == nil {
		panic("function can't be nil")
	}
	f, ok := function.(reflect.Value)
	if !ok {
		f = reflect.ValueOf(function)
	}
	if f.Kind() != reflect.Func {
		panic("function must be func or bound method")
	}
	var options Options
	if len(option) > 0 {
		options = option[0]
	}
	if options.NameSpace != "" && name != "*" {
		name = options.NameSpace + "_" + name
	}
	mm.mmLocker.Lock()
	if mm.RemoteMethods[strings.ToLower(name)] == nil {
		mm.MethodNames = append(mm.MethodNames, name)
	}
	mm.RemoteMethods[strings.ToLower(name)] = &Method{f, options}
	mm.mmLocker.Unlock()
}
1095829
func (t *MockTransactor) CreateTransaction(request fab.TransactionRequest) (*fab.Transaction, error) {
	return txn.New(request)
}