-
Notifications
You must be signed in to change notification settings - Fork 412
Make true/false expression JSON serializable #2537
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
Conversation
| def test_serialize_partition_spec_trye() -> None: | ||
| partitioned = PartitionSpec( | ||
| PartitionField(source_id=1, field_id=1000, transform=TruncateTransform(width=19), name="str_truncate"), | ||
| PartitionField(source_id=2, field_id=1001, transform=BucketTransform(num_buckets=25), name="int_bucket"), | ||
| spec_id=3, | ||
| ) | ||
| assert ( | ||
| partitioned.model_dump_json() | ||
| == """{"spec-id":3,"fields":[{"source-id":1,"field-id":1000,"transform":"truncate[19]","name":"str_truncate"},{"source-id":2,"field-id":1001,"transform":"bucket[25]","name":"int_bucket"}]}""" | ||
| ) | ||
|
|
||
| def test_serialize_partition_spec() -> None: | ||
| partitioned = PartitionSpec( | ||
| PartitionField(source_id=1, field_id=1000, transform=TruncateTransform(width=19), name="str_truncate"), | ||
| PartitionField(source_id=2, field_id=1001, transform=BucketTransform(num_buckets=25), name="int_bucket"), | ||
| spec_id=3, | ||
| ) | ||
| assert ( | ||
| partitioned.model_dump_json() | ||
| == """{"spec-id":3,"fields":[{"source-id":1,"field-id":1000,"transform":"truncate[19]","name":"str_truncate"},{"source-id":2,"field-id":1001,"transform":"bucket[25]","name":"int_bucket"}]}""" | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are copy-paste:
| def test_serialize_partition_spec_trye() -> None: | |
| partitioned = PartitionSpec( | |
| PartitionField(source_id=1, field_id=1000, transform=TruncateTransform(width=19), name="str_truncate"), | |
| PartitionField(source_id=2, field_id=1001, transform=BucketTransform(num_buckets=25), name="int_bucket"), | |
| spec_id=3, | |
| ) | |
| assert ( | |
| partitioned.model_dump_json() | |
| == """{"spec-id":3,"fields":[{"source-id":1,"field-id":1000,"transform":"truncate[19]","name":"str_truncate"},{"source-id":2,"field-id":1001,"transform":"bucket[25]","name":"int_bucket"}]}""" | |
| ) | |
| def test_serialize_partition_spec() -> None: | |
| partitioned = PartitionSpec( | |
| PartitionField(source_id=1, field_id=1000, transform=TruncateTransform(width=19), name="str_truncate"), | |
| PartitionField(source_id=2, field_id=1001, transform=BucketTransform(num_buckets=25), name="int_bucket"), | |
| spec_id=3, | |
| ) | |
| assert ( | |
| partitioned.model_dump_json() | |
| == """{"spec-id":3,"fields":[{"source-id":1,"field-id":1000,"transform":"truncate[19]","name":"str_truncate"},{"source-id":2,"field-id":1001,"transform":"bucket[25]","name":"int_bucket"}]}""" | |
| ) |
Fokko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going in the right direction, left some comments 👍
| def test_always_true_serializes_to_json_true(): | ||
| expr = AlwaysTrue() | ||
| assert expr.model_dump_json() == "true" | ||
|
|
||
| def test_always_false_serializes_to_json_false(): | ||
| expr = AlwaysFalse() | ||
| assert expr.model_dump_json() == "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move these tests to tests/expressions/text_expressions.py?
|
Thanks for working on this @Anubhav007. I'm going to close this since it has been resolved in #2538 |
Fixed JSON serialization of True/False expression