mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 17:00:37 +00:00
Implement Mathematical Functions
This commit is contained in:
650
parsers/nosql/math_functions_test.go
Normal file
650
parsers/nosql/math_functions_test.go
Normal file
@@ -0,0 +1,650 @@
|
||||
package nosql_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
)
|
||||
|
||||
func Test_Execute_MathFunctions(t *testing.T) {
|
||||
t.Run("Should parse function ABS(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT ABS(c.value) FROM c`,
|
||||
parsers.FunctionCallMathAbs,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function ACOS(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT ACOS(c.value) FROM c`,
|
||||
parsers.FunctionCallMathAcos,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function ASIN(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT ASIN(c.value) FROM c`,
|
||||
parsers.FunctionCallMathAsin,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function ATAN(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT ATAN(c.value) FROM c`,
|
||||
parsers.FunctionCallMathAtan,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function CEILING(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT CEILING(c.value) FROM c`,
|
||||
parsers.FunctionCallMathCeiling,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function COS(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT COS(c.value) FROM c`,
|
||||
parsers.FunctionCallMathCos,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function COT(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT COT(c.value) FROM c`,
|
||||
parsers.FunctionCallMathCot,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function DEGREES(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT DEGREES(c.value) FROM c`,
|
||||
parsers.FunctionCallMathDegrees,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function EXP(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT EXP(c.value) FROM c`,
|
||||
parsers.FunctionCallMathExp,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function FLOOR(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT FLOOR(c.value) FROM c`,
|
||||
parsers.FunctionCallMathFloor,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntBitNot(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntBitNot(c.value) FROM c`,
|
||||
parsers.FunctionCallMathIntBitNot,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function LOG10(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT LOG10(c.value) FROM c`,
|
||||
parsers.FunctionCallMathLog10,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function RADIANS(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT RADIANS(c.value) FROM c`,
|
||||
parsers.FunctionCallMathRadians,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function ROUND(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT ROUND(c.value) FROM c`,
|
||||
parsers.FunctionCallMathRound,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function SIGN(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT SIGN(c.value) FROM c`,
|
||||
parsers.FunctionCallMathSign,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function SIN(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT SIN(c.value) FROM c`,
|
||||
parsers.FunctionCallMathSin,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function SQRT(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT SQRT(c.value) FROM c`,
|
||||
parsers.FunctionCallMathSqrt,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function SQUARE(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT SQUARE(c.value) FROM c`,
|
||||
parsers.FunctionCallMathSquare,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function TAN(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT TAN(c.value) FROM c`,
|
||||
parsers.FunctionCallMathTan,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function TRUNC(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT TRUNC(c.value) FROM c`,
|
||||
parsers.FunctionCallMathTrunc,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function ATN2(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT ATN2(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathAtn2,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntAdd(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntAdd(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntAdd,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntBitAnd(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntBitAnd(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntBitAnd,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntBitLeftShift(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntBitLeftShift(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntBitLeftShift,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntBitOr(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntBitOr(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntBitOr,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntBitRightShift(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntBitRightShift(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntBitRightShift,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntBitXor(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntBitXor(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntBitXor,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntDiv(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntDiv(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntDiv,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntMod(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntMod(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntMod,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntMul(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntMul(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntMul,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function IntSub(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT IntSub(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathIntSub,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function POWER(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT POWER(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathPower,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function LOG(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT LOG(c.value) FROM c`,
|
||||
parsers.FunctionCallMathLog,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function LOG(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT LOG(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathLog,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function NumberBin(ex)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT NumberBin(c.value) FROM c`,
|
||||
parsers.FunctionCallMathNumberBin,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function NumberBin(ex1, ex2)", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT NumberBin(c.value, c.secondValue) FROM c`,
|
||||
parsers.FunctionCallMathNumberBin,
|
||||
[]interface{}{
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "value"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
parsers.SelectItem{
|
||||
Path: []string{"c", "secondValue"},
|
||||
Type: parsers.SelectItemTypeField,
|
||||
},
|
||||
},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function PI()", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT PI() FROM c`,
|
||||
parsers.FunctionCallMathPi,
|
||||
[]interface{}{},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse function RAND()", func(t *testing.T) {
|
||||
testMathFunctionParse(
|
||||
t,
|
||||
`SELECT RAND() FROM c`,
|
||||
parsers.FunctionCallMathRand,
|
||||
[]interface{}{},
|
||||
"c",
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func testMathFunctionParse(
|
||||
t *testing.T,
|
||||
query string,
|
||||
expectedFunctionType parsers.FunctionCallType,
|
||||
expectedArguments []interface{},
|
||||
expectedTable string,
|
||||
) {
|
||||
testQueryParse(
|
||||
t,
|
||||
query,
|
||||
parsers.SelectStmt{
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{
|
||||
Type: parsers.SelectItemTypeFunctionCall,
|
||||
Value: parsers.FunctionCall{
|
||||
Type: expectedFunctionType,
|
||||
Arguments: expectedArguments,
|
||||
},
|
||||
},
|
||||
},
|
||||
Table: parsers.Table{Value: expectedTable},
|
||||
},
|
||||
)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -343,6 +343,7 @@ FunctionCall <- StringFunctions
|
||||
/ ArrayFunctions
|
||||
/ InFunction
|
||||
/ AggregateFunctions
|
||||
/ MathFunctions
|
||||
|
||||
StringFunctions <- StringEqualsExpression
|
||||
/ ToStringExpression
|
||||
@@ -384,6 +385,43 @@ ArrayFunctions <- ArrayConcatExpression
|
||||
/ SetIntersectExpression
|
||||
/ SetUnionExpression
|
||||
|
||||
MathFunctions <- MathAbsExpression
|
||||
/ MathAcosExpression
|
||||
/ MathAsinExpression
|
||||
/ MathAtanExpression
|
||||
/ MathCeilingExpression
|
||||
/ MathCosExpression
|
||||
/ MathCotExpression
|
||||
/ MathDegreesExpression
|
||||
/ MathExpExpression
|
||||
/ MathFloorExpression
|
||||
/ MathIntBitNotExpression
|
||||
/ MathLog10Expression
|
||||
/ MathRadiansExpression
|
||||
/ MathRoundExpression
|
||||
/ MathSignExpression
|
||||
/ MathSinExpression
|
||||
/ MathSqrtExpression
|
||||
/ MathSquareExpression
|
||||
/ MathTanExpression
|
||||
/ MathTruncExpression
|
||||
/ MathAtn2Expression
|
||||
/ MathIntAddExpression
|
||||
/ MathIntBitAndExpression
|
||||
/ MathIntBitLeftShiftExpression
|
||||
/ MathIntBitOrExpression
|
||||
/ MathIntBitRightShiftExpression
|
||||
/ MathIntBitXorExpression
|
||||
/ MathIntDivExpression
|
||||
/ MathIntModExpression
|
||||
/ MathIntMulExpression
|
||||
/ MathIntSubExpression
|
||||
/ MathPowerExpression
|
||||
/ MathLogExpression
|
||||
/ MathNumberBinExpression
|
||||
/ MathPiExpression
|
||||
/ MathRandExpression
|
||||
|
||||
UpperExpression <- "UPPER"i ws "(" ex:SelectItem ")" {
|
||||
return createFunctionCall(parsers.FunctionCallUpper, []interface{}{ex})
|
||||
}
|
||||
@@ -527,6 +565,49 @@ SetUnionExpression <- "SetUnion"i ws "(" ws set1:SelectItem ws "," ws set2:Selec
|
||||
return createFunctionCall(parsers.FunctionCallSetUnion, []interface{}{set1, set2})
|
||||
}
|
||||
|
||||
MathAbsExpression <- "ABS"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathAbs, []interface{}{ex}) }
|
||||
MathAcosExpression <- "ACOS"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathAcos, []interface{}{ex}) }
|
||||
MathAsinExpression <- "ASIN"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathAsin, []interface{}{ex}) }
|
||||
MathAtanExpression <- "ATAN"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathAtan, []interface{}{ex}) }
|
||||
MathCeilingExpression <- "CEILING"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathCeiling, []interface{}{ex}) }
|
||||
MathCosExpression <- "COS"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathCos, []interface{}{ex}) }
|
||||
MathCotExpression <- "COT"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathCot, []interface{}{ex}) }
|
||||
MathDegreesExpression <- "DEGREES"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathDegrees, []interface{}{ex}) }
|
||||
MathExpExpression <- "EXP"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathExp, []interface{}{ex}) }
|
||||
MathFloorExpression <- "FLOOR"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathFloor, []interface{}{ex}) }
|
||||
MathIntBitNotExpression <- "IntBitNot"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntBitNot, []interface{}{ex}) }
|
||||
MathLog10Expression <- "LOG10"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathLog10, []interface{}{ex}) }
|
||||
MathRadiansExpression <- "RADIANS"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathRadians, []interface{}{ex}) }
|
||||
MathRoundExpression <- "ROUND"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathRound, []interface{}{ex}) }
|
||||
MathSignExpression <- "SIGN"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathSign, []interface{}{ex}) }
|
||||
MathSinExpression <- "SIN"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathSin, []interface{}{ex}) }
|
||||
MathSqrtExpression <- "SQRT"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathSqrt, []interface{}{ex}) }
|
||||
MathSquareExpression <- "SQUARE"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathSquare, []interface{}{ex}) }
|
||||
MathTanExpression <- "TAN"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathTan, []interface{}{ex}) }
|
||||
MathTruncExpression <- "TRUNC"i ws "(" ws ex:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathTrunc, []interface{}{ex}) }
|
||||
|
||||
MathAtn2Expression <- "ATN2"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathAtn2, []interface{}{set1, set2}) }
|
||||
MathIntAddExpression <- "IntAdd"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntAdd, []interface{}{set1, set2}) }
|
||||
MathIntBitAndExpression <- "IntBitAnd"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntBitAnd, []interface{}{set1, set2}) }
|
||||
MathIntBitLeftShiftExpression <- "IntBitLeftShift"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntBitLeftShift, []interface{}{set1, set2}) }
|
||||
MathIntBitOrExpression <- "IntBitOr"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntBitOr, []interface{}{set1, set2}) }
|
||||
MathIntBitRightShiftExpression <- "IntBitRightShift"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntBitRightShift, []interface{}{set1, set2}) }
|
||||
MathIntBitXorExpression <- "IntBitXor"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntBitXor, []interface{}{set1, set2}) }
|
||||
MathIntDivExpression <- "IntDiv"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntDiv, []interface{}{set1, set2}) }
|
||||
MathIntModExpression <- "IntMod"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntMod, []interface{}{set1, set2}) }
|
||||
MathIntMulExpression <- "IntMul"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntMul, []interface{}{set1, set2}) }
|
||||
MathIntSubExpression <- "IntSub"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathIntSub, []interface{}{set1, set2}) }
|
||||
MathPowerExpression <- "POWER"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" { return createFunctionCall(parsers.FunctionCallMathPower, []interface{}{set1, set2}) }
|
||||
|
||||
MathLogExpression <- "LOG"i ws "(" ws ex1:SelectItem others:(ws "," ws ex:SelectItem { return ex, nil })* ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallMathLog, append([]interface{}{ex1}, others.([]interface{})...))
|
||||
}
|
||||
MathNumberBinExpression <- "NumberBin"i ws "(" ws ex1:SelectItem others:(ws "," ws ex:SelectItem { return ex, nil })* ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallMathNumberBin, append([]interface{}{ex1}, others.([]interface{})...))
|
||||
}
|
||||
MathPiExpression <- "PI"i ws "(" ws ")" { return createFunctionCall(parsers.FunctionCallMathPi, []interface{}{}) }
|
||||
MathRandExpression <- "RAND"i ws "(" ws ")" { return createFunctionCall(parsers.FunctionCallMathRand, []interface{}{}) }
|
||||
|
||||
InFunction <- ex1:SelectProperty ws "IN"i ws "(" ws ex2:SelectItem others:(ws "," ws ex:SelectItem { return ex, nil })* ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallIn, append([]interface{}{ex1, ex2}, others.([]interface{})...))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user