@@ -378,11 +378,28 @@ def literal_to_ibis_scalar(
378
378
scalar_expr = ibis .literal (literal , ibis_dtypes .float64 )
379
379
elif scalar_expr .type ().is_integer ():
380
380
scalar_expr = ibis .literal (literal , ibis_dtypes .int64 )
381
+ elif scalar_expr .type ().is_decimal ():
382
+ precision = scalar_expr .type ().precision
383
+ scale = scalar_expr .type ().scale
384
+ if (precision , scale ) == (76 , 38 ):
385
+ scalar_expr = ibis .literal (
386
+ literal , ibis_dtypes .decimal (precision = 76 , scale = 38 )
387
+ )
388
+ elif (precision , scale ) in ((38 , 9 ), (None , None )):
389
+ scalar_expr = ibis .literal (
390
+ literal , ibis_dtypes .decimal (precision = 38 , scale = 9 )
391
+ )
392
+ else :
393
+ raise TypeError (
394
+ "BigQuery only supports decimal types with precision of 38 and "
395
+ f"scale of 9 (NUMERIC) or precision of 76 and scale of 38 (BIGNUMERIC). "
396
+ f"Current precision: { precision } . Current scale: { scale } "
397
+ )
381
398
382
399
# TODO(bmil): support other literals that can be coerced to compatible types
383
400
if validate and (scalar_expr .type () not in BIGFRAMES_TO_IBIS .values ()):
384
401
raise ValueError (
385
- f"Literal did not coerce to a supported data type: { literal } . { constants .FEEDBACK_LINK } "
402
+ f"Literal did not coerce to a supported data type: { scalar_expr . type () } . { constants .FEEDBACK_LINK } "
386
403
)
387
404
388
405
return scalar_expr
0 commit comments