@@ -209,6 +209,48 @@ func TestCreateIndexChecksum(t *testing.T) {
209209 require .Equal ("1" , driver .config ["idx" ][sql .ChecksumKey ])
210210}
211211
212+ func TestCreateIndexChecksumWithUnderlying (t * testing.T ) {
213+ require := require .New (t )
214+
215+ table :=
216+ & underlyingTable {
217+ & underlyingTable {
218+ & underlyingTable {
219+ & checksumTable {
220+ mem .NewTable ("foo" , sql.Schema {
221+ {Name : "a" , Source : "foo" },
222+ {Name : "b" , Source : "foo" },
223+ {Name : "c" , Source : "foo" },
224+ }),
225+ "1" ,
226+ },
227+ },
228+ },
229+ }
230+
231+ driver := new (mockDriver )
232+ catalog := sql .NewCatalog ()
233+ catalog .RegisterIndexDriver (driver )
234+
235+ exprs := []sql.Expression {
236+ expression .NewGetFieldWithTable (2 , sql .Int64 , "foo" , "c" , true ),
237+ expression .NewGetFieldWithTable (0 , sql .Int64 , "foo" , "a" , true ),
238+ }
239+
240+ ci := NewCreateIndex (
241+ "idx" , NewResolvedTable (table ), exprs , "mock" ,
242+ map [string ]string {"async" : "false" },
243+ )
244+ ci .Catalog = catalog
245+ ci .CurrentDatabase = "foo"
246+
247+ _ , err := ci .RowIter (sql .NewEmptyContext ())
248+ require .NoError (err )
249+
250+ require .Equal ([]string {"idx" }, driver .saved )
251+ require .Equal ("1" , driver .config ["idx" ][sql .ChecksumKey ])
252+ }
253+
212254func TestCreateIndexWithIter (t * testing.T ) {
213255 require := require .New (t )
214256 foo := mem .NewPartitionedTable ("foo" , sql.Schema {
@@ -360,3 +402,9 @@ func (t *checksumTable) Checksum() (string, error) {
360402}
361403
362404func (t * checksumTable ) Underlying () sql.Table { return t .Table }
405+
406+ type underlyingTable struct {
407+ sql.Table
408+ }
409+
410+ func (t * underlyingTable ) Underlying () sql.Table { return t .Table }
0 commit comments