Skip to content

Commit

Permalink
Adding RegexPatterns dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervg committed Oct 23, 2024
1 parent 8e5bf1f commit 3a9fc90
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions blendsql/parse/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sqlglot.optimizer.scope import find_all_in_scope
from attr import attrs, attrib

from .._constants import IngredientKwarg, ModifierType
from .._constants import IngredientKwarg, ModifierType, RegexPatterns
from ._dialect import _parse_one
from . import _checks as check
from . import _transforms as transform
Expand Down Expand Up @@ -411,13 +411,13 @@ def create_regex(
a regex which is restricted to repeat exclusively num_repeats times.
"""
if output_type == "boolean":
base_regex = f"(t|f)"
base_regex = RegexPatterns.BOOLEAN
elif output_type == "integer":
# SQLite max is 18446744073709551615
# This is 20 digits long, so to be safe, cap the generation at 19
base_regex = r"(\d{1,18})"
base_regex = RegexPatterns.INTEGER
elif output_type == "float":
base_regex = r"(\d(\d|\.)*)"
base_regex = RegexPatterns.FLOAT
else:
raise ValueError(f"Unknown output_type {output_type}")
return base_regex
Expand Down

0 comments on commit 3a9fc90

Please sign in to comment.