Skip to content

Conversation

@sfc-gh-yuwang
Copy link
Collaborator

@sfc-gh-yuwang sfc-gh-yuwang commented Dec 4, 2025

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-2866776

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
    • If adding any arguments to public Snowpark APIs or creating new public Snowpark APIs, I acknowledge that I have ensured my changes include AST support. Follow the link for more information: AST Support Guidelines
  3. Please describe how your code solves the related issue.

https://snowpark-python-001.jenkinsdev1.us-west-2.aws-dev.app.snowflake.com/job/SnowparkConnectRegressionRunner/220/
scos test

@sfc-gh-yuwang sfc-gh-yuwang requested review from a team as code owners December 4, 2025 23:57
@sfc-gh-yuwang sfc-gh-yuwang added the NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md label Dec 4, 2025
Comment on lines 172 to 174
def __init__(self, **kwargs) -> None:
self._precision = kwargs.get("precision", None)
self._scale = kwargs.get("scale", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, **kwargs) -> None:
self._precision = kwargs.get("precision", None)
self._scale = kwargs.get("scale", None)
def __init__(self, precision: int | None = None, scale: int | None = None) -> None:
self._precision = precision
self._scale = scale

Can we do this style instead to make it more explicit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a internal only feature, I think we don't want to expose this information to customer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, we can just keep it as kwargs then.

What do you think about moving the arguments onto _IntegralType instead of _NumericType? It looks like Snowflake only has a single precision for FLOAT and DECIMAL (docs), so we should never have to expose precision information for those types.

Copy link
Contributor

@sfc-gh-aling sfc-gh-aling Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on using _IntegralType, I don't think we need _scale as it would always be 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, will fix this

@sfc-gh-yuwang
Copy link
Collaborator Author

sfc-gh-yuwang commented Dec 5, 2025

I modified eq function to exclude _precision and _scale

Comment on lines 176 to 182
def __eq__(self, other):
def filtered(d: dict) -> dict:
return {k: v for k, v in d.items() if k not in ("_precision", "_scale")}

return isinstance(other, self.__class__) and filtered(
self.__dict__
) == filtered(other.__dict__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we overwrite the logic to exclude the new prop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is a example test:
expected_fields = [
StructField("COL1", LongType(), nullable=True),
StructField("COL2", LongType(), nullable=True),
]
assert df.schema.fields == expected_fields
we exclude the private var so that these existing test does not fail

) == filtered(other.__dict__)

def __hash__(self):
return hash(repr(self))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a custom hash implementation for this class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL:DR: this is to fix some test failure
when you defined eq, you need to redefine hash otherwise it is considered None

Comment on lines 377 to 382
def filtered(d: dict) -> dict:
return {k: v for k, v in d.items() if k != "_precision"}

return isinstance(other, self.__class__) and filtered(
self.__dict__
) == filtered(other.__dict__)
Copy link
Contributor

@sfc-gh-aling sfc-gh-aling Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think whether excluding precision or not should be based upon the context._is_snowpark_connect_mode.

scos they might want to distinguish LongType by precision


if kwargs != {}:
raise TypeError(
f"__init__() takes 0 argument but {len(kwargs.keys())} were given"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar Error in Exception Message

The error message uses singular "argument" but will be grammatically incorrect when multiple arguments are passed.

# Current: "takes 0 argument but 2 were given" (incorrect grammar)

Fix: Use proper singular/plural form:

arg_word = "argument" if len(kwargs) == 1 else "arguments"
raise TypeError(
    f"__init__() takes 0 arguments but {len(kwargs)} {arg_word if len(kwargs) != 1 else 'was'} given"
)

Or simply use plural consistently:

raise TypeError(
    f"__init__() takes 0 arguments but {len(kwargs)} were given"
)

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@sfc-gh-yuwang
Copy link
Collaborator Author

I still kept the eq function in TimedeltaType class.
Otherwise it will treat LongType() == TimedeltaType() which is wrong.

@sfc-gh-yuwang sfc-gh-yuwang merged commit bcba153 into main Dec 8, 2025
26 of 29 checks passed
@sfc-gh-yuwang sfc-gh-yuwang deleted the SNOW-2866776 branch December 8, 2025 04:36
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md snowpark-pandas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants