mirror of
https://github.com/minio/minio.git
synced 2025-02-04 02:15:59 -05:00
s3 select: Infer types for comparison (#9438)
This commit is contained in:
parent
20766069a8
commit
e4900b99d7
@ -573,6 +573,16 @@ func TestCSVQueries2(t *testing.T) {
|
|||||||
query: `SELECT num2 from s3object s WHERE id = 2`,
|
query: `SELECT num2 from s3object s WHERE id = 2`,
|
||||||
wantResult: `{"num2":" 0.765111"}`,
|
wantResult: `{"num2":" 0.765111"}`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "select-in-array",
|
||||||
|
query: `select id from S3Object s WHERE id in [1,3]`,
|
||||||
|
wantResult: `{"id":"1"}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "select-in-array-matchnone",
|
||||||
|
query: `select id from S3Object s WHERE s.id in [4,3]`,
|
||||||
|
wantResult: ``,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "select-float-by-val",
|
name: "select-float-by-val",
|
||||||
query: `SELECT num2 from s3object s WHERE num2 = 0.765111`,
|
query: `SELECT num2 from s3object s WHERE num2 = 0.765111`,
|
||||||
|
@ -250,6 +250,9 @@ func (e *In) evalInNode(r Record, lhs *Value) (*Value, error) {
|
|||||||
// Compare two values in terms of in-ness.
|
// Compare two values in terms of in-ness.
|
||||||
var cmp func(a, b Value) bool
|
var cmp func(a, b Value) bool
|
||||||
cmp = func(a, b Value) bool {
|
cmp = func(a, b Value) bool {
|
||||||
|
// Convert if needed.
|
||||||
|
inferTypesForCmp(&a, &b)
|
||||||
|
|
||||||
if a.Equals(b) {
|
if a.Equals(b) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -272,7 +275,6 @@ func (e *In) evalInNode(r Record, lhs *Value) (*Value, error) {
|
|||||||
aF, aOK := a.ToFloat()
|
aF, aOK := a.ToFloat()
|
||||||
bF, bOK := b.ToFloat()
|
bF, bOK := b.ToFloat()
|
||||||
|
|
||||||
// FIXME: more type inference?
|
|
||||||
return aOK && bOK && aF == bF
|
return aOK && bOK && aF == bF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user