ValueError: invalid literal for int() with base 36
See original GitHub issueHi Team,
I am trying to run diff between postgres and bq. My primary key column is string(uuid). Example - ‘zZsNL-xxt2o-REN’
When doing the diff, I am getting the following exception:
[2022-09-05, 11:40:45 AEST] {taskinstance.py:1902} ERROR - Task failed with exception
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.8/site-packages/data_diff/diff_tables.py", line 421, in _parse_key_range_result
return cls(mn), cls(mx) + 1
File "/home/airflow/.local/lib/python3.8/site-packages/data_diff/utils.py", line 94, in __add__
res = self.new(int=self.int + other)
File "/home/airflow/.local/lib/python3.8/site-packages/data_diff/utils.py", line 75, in int
return int(self._str, len(alphanums))
ValueError: invalid literal for int() with base 36: 'zZsNL-xxt2o-REN'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/operators/python.py", line 171, in execute
return_value = self.execute_callable()
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/operators/python.py", line 189, in execute_callable
return self.python_callable(*self.op_args, **self.op_kwargs)
File "/opt/airflow/dags/dataquality_metrics/utils/quality_metrics.py", line 54, in find_missing_rows
raise ev
File "/opt/airflow/dags/dataquality_metrics/utils/quality_metrics.py", line 48, in find_missing_rows
diff = list(dif_iter)
File "/home/airflow/.local/lib/python3.8/site-packages/data_diff/diff_tables.py", line 414, in diff_tables
raise error
File "/home/airflow/.local/lib/python3.8/site-packages/data_diff/diff_tables.py", line 367, in diff_tables
min_key1, max_key1 = self._parse_key_range_result(key_type, next(key_ranges))
File "/home/airflow/.local/lib/python3.8/site-packages/data_diff/diff_tables.py", line 423, in _parse_key_range_result
raise type(e)(f"Cannot apply {key_type} to {mn}, {mx}.") from e
ValueError: Cannot apply String_Alphanum(length=15) to 016AL-NjNQP-REN, zZsNL-xxt2o-REN.
I have tried recreating this error by taking the following samples from utils.py code
import string
alphanums = string.digits + string.ascii_lowercase
def numberToBase(num, base):
digits = []
while num > 0:
num, remainder = divmod(num, base)
digits.append(remainder)
return "".join(alphanums[i] for i in digits[::-1])
xx = 'zZsNL-xxt2o-REN'
yy = int(xx, len(alphanums))
str = numberToBase(yy, len(alphanums))
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
ValueError: invalid literal for int () with base 10 - Stack Overflow
Answer: Your traceback is telling you that int() takes integers, you are trying to give a decimal, so you need to use float()...
Read more >ValueError: invalid literal for int() with base 10
The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that's not an...
Read more >What is the meaning of invalid literal for int() with base = ' '?
Here, we are talking about the ValueError caused by passing an incorrect argument to the int() function. When we pass a string representation...
Read more >How to fix this ValueError invalid literal for int with base 10 ...
The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that's not an...
Read more >Python ValueError: invalid literal for int() with base 10
When passing int() a string-type object which looks like a float-type (e.g., the string '56.3' ). Although technically, this is an extension of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I understand your use-case, it makes sense to me.
Keys of varying size aren’t supported right now, but they are on our TODO. I believe they shouldn’t be too hard to add.
As for (2), I wouldn’t consider
-
to be alphanumeric. Do you have any other non-alphanumeric characters? Or is it only “a” to “z”, “A” to “Z”, and “-” ?Fixed and merged to master.