(ctx []antlrgen.IExpressionContext, def string)
| 1491 | } |
| 1492 | |
| 1493 | func (v *ASTBuilder) setNumericBucketizer(ctx []antlrgen.IExpressionContext, def string) { |
| 1494 | switch def { |
| 1495 | case util.NumericBucketTypeBucketWidth: |
| 1496 | location := v.getLocation(ctx[1]) |
| 1497 | value, err := strconv.ParseFloat(util.TrimQuote(v.getText(ctx[1])), 64) |
| 1498 | if err != nil { |
| 1499 | panic(fmt.Errorf("expect float value at (line:%d, col:%d)", |
| 1500 | location.Line, location.CharPosition)) |
| 1501 | } |
| 1502 | v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey] = append( |
| 1503 | v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey], |
| 1504 | queryCom.Dimension{ |
| 1505 | Expr: util.TrimQuote(v.getText(ctx[0])), |
| 1506 | NumericBucketizer: queryCom.NumericBucketizerDef{BucketWidth: value}, |
| 1507 | }) |
| 1508 | case util.NumericBucketTypeLogBase: |
| 1509 | location := v.getLocation(ctx[1]) |
| 1510 | value, err := strconv.ParseFloat(util.TrimQuote(v.getText(ctx[1])), 64) |
| 1511 | if err != nil { |
| 1512 | panic(fmt.Errorf("expect float value at (line:%d, col:%d)", |
| 1513 | location.Line, location.CharPosition)) |
| 1514 | } |
| 1515 | v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey] = append( |
| 1516 | v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey], |
| 1517 | queryCom.Dimension{ |
| 1518 | Expr: util.TrimQuote(v.getText(ctx[0])), |
| 1519 | NumericBucketizer: queryCom.NumericBucketizerDef{LogBase: value}, |
| 1520 | }) |
| 1521 | case util.NumericBucketTypeManualPartitions: |
| 1522 | location := v.getLocation(ctx[1]) |
| 1523 | values := strings.Split(util.TrimQuote(v.getText(ctx[1])), ",") |
| 1524 | partitions := make([]float64, len(values), len(values)) |
| 1525 | for i, value := range values { |
| 1526 | partition, err := strconv.ParseFloat(value, 64) |
| 1527 | if err != nil { |
| 1528 | panic(fmt.Errorf("expect float value at (line:%d, col:%d)", |
| 1529 | location.Line, location.CharPosition)) |
| 1530 | } |
| 1531 | partitions[i] = partition |
| 1532 | } |
| 1533 | v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey] = append( |
| 1534 | v.SQL2AqlCtx.MapDimensions[v.SQL2AqlCtx.mapKey], |
| 1535 | queryCom.Dimension{ |
| 1536 | Expr: util.TrimQuote(v.getText(ctx[0])), |
| 1537 | NumericBucketizer: queryCom.NumericBucketizerDef{ManualPartitions: partitions}, |
| 1538 | }) |
| 1539 | } |
| 1540 | } |
| 1541 | |
| 1542 | // mergeWithOrSubQueries merge all subquery/withQuery's information into v.aql |
| 1543 | func (v *ASTBuilder) mergeWithOrSubQueries() { |
no test coverage detected