Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions enginetest/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -8719,6 +8719,14 @@ from typestable`,
{1, 0, 3, 2},
},
},
{
Query: "select * from mytable where i > '-0.5';",
Copy link
Copy Markdown
Contributor

@max-hoffman max-hoffman Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried an index lookup but I'm not seeing the same issue for some reason, does that make sense that it's just static range scans?

select /*+ LOOKUP_JOIN(b,a) */ * from mytable a join mytable b on a.i = '-.5' and a.s = b.s
Project
 ├─ columns: [a.i:2!null, a.s:3!null, b.i:0!null, b.s:1!null]
 └─ LookupJoin
     ├─ Eq
     │   ├─ a.s:3!null
     │   └─ b.s:1!null
     ├─ TableAlias(b)
     │   └─ Table
     │       ├─ name: mytable
     │       ├─ columns: [i s]
     │       ├─ colSet: (3,4)
     │       └─ tableId: 2
     └─ Filter
         ├─ Eq
         │   ├─ a.i:0!null
         │   └─ -.5 (longtext)
         └─ TableAlias(a)
             └─ IndexedTableAccess(mytable)
                 ├─ index: [mytable.i]
                 ├─ keys: [-.5 (longtext)]
                 ├─ colSet: (1,2)
                 ├─ tableId: 1
                 └─ Table
                     ├─ name: mytable
                     └─ columns: [i s]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it hits this case if we are using a lookup join:
https://github.com/dolthub/go-mysql-server/pull/2246/files#diff-66b16c24d40520a9c552a4093466441a1623797f6aea41f208809bf2eee3de8cR114

(The range is empty unless its a whole number)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk, so I guess this bug only applies to non-equalities.

Expected: []sql.Row{
{1, "first row"},
{2, "second row"},
{3, "third row"},
},
},
}

var KeylessQueries = []QueryTest{
Expand Down
16 changes: 16 additions & 0 deletions sql/index_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ func ceil(val interface{}) interface{} {
return math.Ceil(v)
case decimal.Decimal:
return v.Ceil()
case string:
dec, err := decimal.NewFromString(v)
if err != nil {
return v
}
return ceil(dec)
case []byte:
return ceil(string(v))
default:
return v
}
Expand All @@ -77,6 +85,14 @@ func floor(val interface{}) interface{} {
return math.Floor(v)
case decimal.Decimal:
return v.Floor()
case string:
dec, err := decimal.NewFromString(v)
if err != nil {
return v
}
return floor(dec)
case []byte:
return floor(string(v))
default:
return v
}
Expand Down