Skip to content

Commit 2e5afe7

Browse files
committed
Update inferred max value for DecimalType columns
1 parent ff5d483 commit 2e5afe7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dbldatagen/data_analyzer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def summarizeToDF(self) -> DataFrame:
227227
measureName="min",
228228
fieldExprs=[f"string(min({dtype[0]})) as {dtype[0]}" for dtype in dtypes],
229229
dfData=self._df,
230-
dfSummary=data_summary_df)
230+
dfSummary=data_summary_df
231+
)
231232

232233
data_summary_df = self._addMeasureToSummary(
233234
measureName="max",
@@ -384,8 +385,9 @@ def _generatorDefaultAttributesFromType(
384385
result = """expr='current_date()'"""
385386

386387
elif isinstance(sqlType, types.DecimalType):
388+
max_decimal_value = 10**(sqlType.precision - sqlType.scale) - 10**(-1 * sqlType.scale)
387389
min_value = cls._valueFromSummary(dataSummary, colName, "min", defaultValue=0)
388-
max_value = cls._valueFromSummary(dataSummary, colName, "max", defaultValue=1000)
390+
max_value = cls._valueFromSummary(dataSummary, colName, "max", defaultValue=max_decimal_value)
389391
result = f"""minValue={min_value}, maxValue={max_value}"""
390392

391393
elif sqlType in [types.FloatType(), types.DoubleType()]:

0 commit comments

Comments
 (0)