Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nullQuota leads to all null values on int/double attributes #460

Open
GPSHansl opened this issue Aug 2, 2024 · 1 comment
Open

nullQuota leads to all null values on int/double attributes #460

GPSHansl opened this issue Aug 2, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@GPSHansl
Copy link

GPSHansl commented Aug 2, 2024

Describe the bug

nullQuota not working on number attributes, generator is always created as "ConstantGenerator(null, ...)" because parameter "SimpleTypeGeneratorFactory.createSpecificGenerator(..., nullable, ...)" (line 137ff) is not "false" .

To Reproduce

I created a simple "setup" which should create 20 datasets for ints, one without nullQuota, one with a "nullQuota" of "0.5".

<setup xmlns="https://www.benerator.de/schema/3.0.0">
	<generate type="test_withNullQuota" count="20" consumer="ConsoleExporter">
		<attribute name="number0" type="int" />
		<attribute name="number1" type="int" nullQuota="0.5" />
	</generate>
</setup>

Output:

test_withNullQuota[number0=1824111337, number1=[null]]
test_withNullQuota[number0=379015914, number1=[null]]
test_withNullQuota[number0=472367231, number1=[null]]
test_withNullQuota[number0=709014741, number1=[null]]
test_withNullQuota[number0=1042858519, number1=[null]]
test_withNullQuota[number0=1565994621, number1=[null]]
...
test_withNullQuota[number0=1891265572, number1=[null]]
test_withNullQuota[number0=62328256, number1=[null]]
test_withNullQuota[number0=935388951, number1=[null]]
test_withNullQuota[number0=366984187, number1=[null]]
test_withNullQuota[number0=1042493533, number1=[null]]

Expected behavior

On execution I'd expect, that on any entry the "number0" is filled with a random int number, that's what's happened.
I also expect that on about half the entries the "number1" is filled with a random int number, the rest of the entries have "number1" filled with "null".

test_withNullQuota[number0=1824111337, number1=[null]]
test_withNullQuota[number0=379015914, number1=[19194731]]
test_withNullQuota[number0=709014741, number1=[41651919]]
test_withNullQuota[number0=472367231, number1=[null]]
....
test_withNullQuota[number0=1042858519, number1=[null]]
test_withNullQuota[number0=1565994621, number1=[4919089]]
test_withNullQuota[number0=1602994586, number1=[null]]

Suspections

I suspect, the "nullable" parameter, derived within the "InstanceGeneratorFactory.createSingleInstanceGenerator(...) (line 59ff, derived at line 81) is not completely correct for the generator, since "nullQuota" "null" values should be created by some null-creator-wrapper, whereas the generator itself should always return non null values.

Benerator Version

I hope my report is sufficient.
Maybe I have a big misunderstanding on attribute generation and nullQuotas.
Maybe I have just to set a "defaultNullQuota" ("context.getGeneratorFactory().getDefaultsProvider().defaultNullQuota() queried in "TypeGeneratorFactory.shouldNullifyEachNullable(...)") but I don't know how.

@ake2l
Copy link
Member

ake2l commented Aug 7, 2024

Hey , thanks for using Benerator and for your detailed report. We are checking this and come back to you ASAP ... but first impression , it seems like a bug .

@ake2l ake2l self-assigned this Aug 7, 2024
@ake2l ake2l added the bug Something isn't working label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants