mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix the bug of long type value overflow (#8313)
### What problem does this PR solve? This PR will fix the #8271 by extending int type to float type when there is any value out of long type range in a column. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -92,11 +92,15 @@ def column_data_type(arr):
|
|||||||
arr = list(arr)
|
arr = list(arr)
|
||||||
counts = {"int": 0, "float": 0, "text": 0, "datetime": 0, "bool": 0}
|
counts = {"int": 0, "float": 0, "text": 0, "datetime": 0, "bool": 0}
|
||||||
trans = {t: f for f, t in [(int, "int"), (float, "float"), (trans_datatime, "datetime"), (trans_bool, "bool"), (str, "text")]}
|
trans = {t: f for f, t in [(int, "int"), (float, "float"), (trans_datatime, "datetime"), (trans_bool, "bool"), (str, "text")]}
|
||||||
|
float_flag = False
|
||||||
for a in arr:
|
for a in arr:
|
||||||
if a is None:
|
if a is None:
|
||||||
continue
|
continue
|
||||||
if re.match(r"[+-]?[0-9]{,19}(\.0+)?$", str(a).replace("%%", "")):
|
if re.match(r"[+-]?[0-9]+$", str(a).replace("%%", "")):
|
||||||
counts["int"] += 1
|
counts["int"] += 1
|
||||||
|
if int(str(a)) > 2**63 - 1:
|
||||||
|
float_flag = True
|
||||||
|
break
|
||||||
elif re.match(r"[+-]?[0-9.]{,19}$", str(a).replace("%%", "")):
|
elif re.match(r"[+-]?[0-9.]{,19}$", str(a).replace("%%", "")):
|
||||||
counts["float"] += 1
|
counts["float"] += 1
|
||||||
elif re.match(r"(true|yes|是|\*|✓|✔|☑|✅|√|false|no|否|⍻|×)$", str(a), flags=re.IGNORECASE):
|
elif re.match(r"(true|yes|是|\*|✓|✔|☑|✅|√|false|no|否|⍻|×)$", str(a), flags=re.IGNORECASE):
|
||||||
@ -105,6 +109,9 @@ def column_data_type(arr):
|
|||||||
counts["datetime"] += 1
|
counts["datetime"] += 1
|
||||||
else:
|
else:
|
||||||
counts["text"] += 1
|
counts["text"] += 1
|
||||||
|
if float_flag:
|
||||||
|
ty = "float"
|
||||||
|
else:
|
||||||
counts = sorted(counts.items(), key=lambda x: x[1] * -1)
|
counts = sorted(counts.items(), key=lambda x: x[1] * -1)
|
||||||
ty = counts[0][0]
|
ty = counts[0][0]
|
||||||
for i in range(len(arr)):
|
for i in range(len(arr)):
|
||||||
|
|||||||
Reference in New Issue
Block a user