nineinchnick / trino-faker

Trino plugin that generates fake data
Apache License 2.0
14 stars 2 forks source link

Push down predicates to limit generated values #19

Closed nineinchnick closed 2 years ago

nineinchnick commented 2 years ago

It should be possible to limit the range of generated values by pushing down predicates, especially for numerical and date/time types:

SELECT * FROM faker.default.some_table WHERE int_col BETWEEN 1 AND 5 AND ts_col > NOW - INTERVAL '5' DAY

For character types only allow pushing down = where values would be treated as Faker expressions.

More complex predicates (like OR) should throw an exception.

It would be nice to be able to reference other columns, but if it's hard to implement create a follow-up issue.

nineinchnick commented 2 years ago

Turns out this is a lot of work to support all data types because it needs to handle:

Because of this, the initial implementation won't allow for multiple ranges on the same column.

nineinchnick commented 2 years ago

Done in 94244cbc40ba458096333751f02a2fc1035b1474 with a few caveats