Skip to content

Commit 57d0285

Browse files
authored
feat: Make more data dynamic (#2197)
#### Summary This PR makes more fields dynamic, based on the random number seed. The data stays deterministic, but enables each row to have a different value
1 parent 0e8e1c1 commit 57d0285

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

schema/testdata.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,26 @@ func (tg TestDataGenerator) getExampleJSON(colName string, dataType arrow.DataTy
307307
if opts.UseHomogeneousType {
308308
return `{"test":["a", "b", "c"]}`
309309
}
310-
return `{"test":["a","b",3]}`
310+
return fmt.Sprintf(`{"test":["a","b",%d]}`, rnd.Intn(100000))
311311
}
312312
if arrow.TypeEqual(dataType, types.ExtensionTypes.Inet) {
313-
return `"192.0.2.0/24"`
313+
// Create a random IPv4 address
314+
ip := make([]byte, 4)
315+
_, _ = rnd.Read(ip)
316+
317+
// Generate a CIDR prefix length between 8 and 30
318+
cidr := 8 + rnd.Intn(23)
319+
320+
// Format as an IP address with CIDR notation
321+
return fmt.Sprintf(`"%d.%d.%d.%d/%d"`, ip[0], ip[1], ip[2], ip[3], cidr)
314322
}
315323
if arrow.TypeEqual(dataType, types.ExtensionTypes.MAC) {
316-
return `"aa:bb:cc:dd:ee:ff"`
324+
mac := make([]byte, 6)
325+
_, _ = rnd.Read(mac)
326+
// Ensure it's a unicast address (clear the multicast bit)
327+
mac[0] &= 0xfe
328+
// Format as a MAC address string
329+
return fmt.Sprintf(`"%02x:%02x:%02x:%02x:%02x:%02x"`, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5])
317330
}
318331

319332
// handle signed integers

0 commit comments

Comments
 (0)