Skip to content
Merged
Changes from 1 commit
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
19 changes: 16 additions & 3 deletions schema/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,26 @@ func (tg TestDataGenerator) getExampleJSON(colName string, dataType arrow.DataTy
if opts.UseHomogeneousType {
return `{"test":["a", "b", "c"]}`
}
return `{"test":["a","b",3]}`
return fmt.Sprintf(`{"test":["a","b",%d]}`, rnd.Intn(100000))
}
if arrow.TypeEqual(dataType, types.ExtensionTypes.Inet) {
return `"192.0.2.0/24"`
// Create a random IPv4 address
ip := make([]byte, 4)
_, _ = rnd.Read(ip)

// Generate a CIDR prefix length between 8 and 30
cidr := 8 + rnd.Intn(23)

// Format as an IP address with CIDR notation
return fmt.Sprintf(`"%d.%d.%d.%d/%d"`, ip[0], ip[1], ip[2], ip[3], cidr)
}
if arrow.TypeEqual(dataType, types.ExtensionTypes.MAC) {
return `"aa:bb:cc:dd:ee:ff"`
mac := make([]byte, 6)
_, _ = rnd.Read(mac)
// Ensure it's a unicast address (clear the multicast bit)
mac[0] &= 0xfe
// Format as a MAC address string
return fmt.Sprintf(`"%02x:%02x:%02x:%02x:%02x:%02x"`, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5])
}

// handle signed integers
Expand Down