0

I try to parse WKT and create GEOMETRY type with Snowpark Python API, but it fails:

session.sql("select to_geometry('POINT(1820.12 890.56)')").show()

TypeError: '>' not supported between instances of 'NoneType' and 'int'

I tested both Version 0.9.0 and 0.8.0, same result

The above SQL works fine in Snowflake's worksheets

Raphael Roth
  • 26,751
  • 15
  • 88
  • 145

2 Answers2

0

It seems Snowpark Python can not handle the output of the geometry objects when showing. This is the failing code in type_utils.py:

if column_type_name == "DECIMAL" or (
    (column_type_name == "FIXED" or column_type_name == "NUMBER") and scale != 0
):
    if precision != 0 or scale != 0:
        if precision > DecimalType._MAX_PRECISION:
            return DecimalType(
                DecimalType._MAX_PRECISION,
                scale + precision - DecimalType._MAX_SCALE,
            )
        else:
            return DecimalType(precision, scale)
    else:
        return DecimalType(38, 18)

The code fails when it can't determine the precision. So adding a check mitigates the issue:

if column_type_name == "DECIMAL" or (
    (column_type_name == "FIXED" or column_type_name == "NUMBER") and scale != 0
):
    if precision is None:
        return DecimalType(precision, scale)
    if precision != 0 or scale != 0:
        if precision > DecimalType._MAX_PRECISION:
            return DecimalType(
                DecimalType._MAX_PRECISION,
                scale + precision - DecimalType._MAX_SCALE,
            )
        else:
            return DecimalType(precision, scale)
    else:
        return DecimalType(38, 18)

Please submit a support ticket to Snowflake, so the code can be fixed.

Gokhan Atil
  • 9,278
  • 2
  • 11
  • 24
0

Support of GEOMETRY was added in Snowpark v.1.5.1