Skip to content

Commit

Permalink
Merge branch 'main' into literal_revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
EpsilonPrime authored Jan 11, 2025
2 parents f139052 + 8c4fdcb commit 9b9759b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions expr/decimal_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/cockroachdb/apd/v3"
)

var decimalPattern = regexp.MustCompile(`^[+-]?\d{0,38}(\.\d{0,38})?([eE][+-]?\d{0,38})?$`)
var decimalPattern = regexp.MustCompile(`^[+-]?\d*(\.\d*)?([eE][+-]?\d*)?$`)

// DecimalStringToBytes converts a decimal string to a 16-byte byte array.
// 16-byte bytes represents a little-endian 128-bit integer, to be divided by 10^Scale to get the decimal value.
Expand All @@ -31,7 +31,7 @@ func DecimalStringToBytes(decimalStr string) ([16]byte, int32, int32, error) {
// Parse the decimal string using apd
dec, cond, err := apd.NewFromString(decimalStr)
if err != nil || cond.Any() {
return result, 0, 0, fmt.Errorf("invalid decimal string: %v", err)
return result, 0, 0, fmt.Errorf("invalid decimal string %s: %v", decimalStr, err)
}

if dec.Exponent > 0 {
Expand All @@ -42,7 +42,7 @@ func DecimalStringToBytes(decimalStr string) ([16]byte, int32, int32, error) {
precision = max(int32(apd.NumDigits(&dec.Coeff)), scale+1)
}
if precision > 38 {
return result, precision, scale, fmt.Errorf("number exceeds maximum precision of 38")
return result, precision, scale, fmt.Errorf("number %s exceeds maximum precision of 38 (%d)", decimalStr, precision)
}

coefficient := dec.Coeff
Expand Down
2 changes: 0 additions & 2 deletions testcases/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,6 @@ func TestLoadAllSubstraitTestFiles(t *testing.T) {
for _, filePath := range filePaths {
t.Run(filePath, func(t *testing.T) {
switch filePath {
case "tests/cases/boolean/bool_and.test":
t.Skip("Skipping bool_and.test")
case "tests/cases/datetime/extract.test":
// TODO deal with enum arguments in testcase
t.Skip("Skipping extract.test")
Expand Down

0 comments on commit 9b9759b

Please sign in to comment.