Closed
Description
Attempting to add an index to a generated column fails if the value in the generated column expression requires a conversion.
Example:
CREATE TABLE test (pk INT PRIMARY KEY, f FLOAT GENERATED ALWAYS AS (1));
INSERT INTO test (pk) VALUES (1);
CREATE INDEX i ON test (f);
Expected behavior: index is successfully created.
Actual behavior:
panic: interface conversion: interface {} is int8, not float32
goroutine 1 [running]:
github.com/dolthub/dolt/go/store/prolly/tree.PutField({0x103edd980?, 0x14000b5c6e0?}, {0x103eeb270?, 0x14000b0a3c0?}, 0x1400112e180?, 0x2?, {0x1039a9540?, 0x1054c9828?})
/Users/nick/Documents/dolt/go/store/prolly/tree/prolly_fields.go:205 +0x17f0
github.com/dolthub/dolt/go/libraries/doltcore/sqle/index.SecondaryKeyBuilder.SecondaryKeyFromRow({{0x103f788a0, 0x14000dd6e00}, {0x103f79610, 0x140000cac00}, {0x14001130180, 0x2, 0x2}, {0x14001187f20, 0x2, 0x2}, ...}, ...)
/Users/nick/Documents/dolt/go/libraries/doltcore/sqle/index/key_builder.go:127 +0x4b0
github.com/dolthub/dolt/go/libraries/doltcore/table/editor/creation.BuildProllyIndexExternal(_, {_, _}, {_, _}, {_, _}, {_, _}, {_, ...}, ...)
/Users/nick/Documents/dolt/go/libraries/doltcore/table/editor/creation/external_build_index.go:87 +0x6f8
github.com/dolthub/dolt/go/libraries/doltcore/table/editor/creation.BuildSecondaryProllyIndex(_, {_, _}, {_, _}, {_, _}, {_, _}, {_, ...}, ...)
/Users/nick/Documents/dolt/go/libraries/doltcore/table/editor/creation/index.go:179 +0x18c
github.com/dolthub/dolt/go/libraries/doltcore/table/editor/creation.BuildSecondaryIndex(0x14000b5c6e0, 0x14001187e60, {0x103f79610, 0x140000cac00}, {0x14000d71490, 0x8}, {0x0, {0x103ecc670, 0x14000f9c720}, {0x14000b38c90, ...}})
/Users/nick/Documents/dolt/go/libraries/doltcore/table/editor/creation/index.go:153 +0x308
...
Activity