Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectors with infinities can be created #58379

Open
kennytm opened this issue Dec 18, 2024 · 1 comment
Open

Vectors with infinities can be created #58379

kennytm opened this issue Dec 18, 2024 · 1 comment
Labels
affects-8.4 affects-8.5 This bug affects the 8.5.x(LTS) versions. sig/vector type/bug The issue is confirmed as a bug.

Comments

@kennytm
Copy link
Contributor

kennytm commented Dec 18, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

select vec_from_text('[1e39, -1e39]') _;

2. What did you expect to see? (Required)

ERROR 1105 (HY000): Invalid vector text: [1e39, -1e39]

(it should actually mention "infinite value not allowed in vector" as well but that's another matter)

3. What did you see instead (Required)

+-------------+
| _           |
+-------------+
| [+Inf,-Inf] |
+-------------+
1 row in set (0.00 sec)

Such vector can produce a scalar Infinity or NaN as well

mysql> select VEC_L2_NORM('[1e39]') + 1;
ERROR 1690 (22003): DOUBLE value is out of range in '(+Inf + 1)'
mysql> select VEC_L2_NORM('[1e39]')*0 + 1;
ERROR 1690 (22003): DOUBLE value is out of range in '(NaN + 1)'

4. What is your TiDB version? (Required)

Today's nightly.

Release Version: v8.5.0-alpha-373-g177a03c8e5
Edition: Community
Git Commit Hash: 177a03c8e51caf844491d8a93edda29295510e8d
Git Branch: HEAD
UTC Build Time: 2024-12-18 05:08:16
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv
@kennytm kennytm added affects-8.4 affects-8.5 This bug affects the 8.5.x(LTS) versions. sig/vector type/bug The issue is confirmed as a bug. labels Dec 18, 2024
@kennytm
Copy link
Contributor Author

kennytm commented Dec 18, 2024

tidb/pkg/types/vector.go

Lines 226 to 238 in 0be1983

parser.ReadArrayCB(func(parser *jsoniter.Iterator) bool {
v := parser.ReadFloat64()
if math.IsNaN(v) {
valueError = errors.Errorf("NaN not allowed in vector")
return false
}
if math.IsInf(v, 0) {
valueError = errors.Errorf("infinite value not allowed in vector")
return false
}
values = append(values, float32(v))
return true
})

Just because a number is finite in f64 does not mean it is finite when converted to f32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.4 affects-8.5 This bug affects the 8.5.x(LTS) versions. sig/vector type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

1 participant