GoogleCloudPlatform / GoogleCloudPlatform/professional-services-data-validator
Unhandled exception from generate-table-partitions on an empty table
- Dominant language
- Python
- Stars
- 524
- Forks
- 171
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 4
Description
Test case:
```
SQL> create table dvt_test.tab_empty (id number(5), data varchar2(30));
$ data-validation generate-table-partitions -sc ora -tc ora -tbls dvt_test.tab_empty --primary-keys id --hash '*' --config-dir "/tmp/empty.yaml" --partition-num 2
Traceback (most recent call last):
...
File "/home/xyz/professional-services-data-validator/data_validation/partition_builder.py", line 283, in _get_partition_key_filters
first_elements[1, : len(source_pks)],
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
IndexError: index 1 is out of bounds for axis 0 with size 0
```
Obviously there's not much we can dio with an empty table but a better exception would make sense.
Contributor guide
Research direction
Start with the generate-table-partitions command and data_validation/partition_builder.py, especially _get_partition_key_filters. Reproduce the command against an empty table, trace the empty result to the reported IndexError, and define a clearer exception for this case; done means the command no longer exposes that traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100