Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1867961: from_json does not work for TimestampType if it contains tz_info #2809

Open
AdamosX opened this issue Dec 23, 2024 · 3 comments
Assignees
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team

Comments

@AdamosX
Copy link

AdamosX commented Dec 23, 2024

Relevant functions:

def _parse_datatype_json_value(json_value: Union[dict, str]) -> DataType:

def json_value(self) -> str:

@github-actions github-actions bot changed the title from_json does not work for TimestampType if it contains tz_info SNOW-1867961: from_json does not work for TimestampType if it contains tz_info Dec 23, 2024
@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Dec 24, 2024
@sfc-gh-sghosh sfc-gh-sghosh added the status-triage Issue is under initial triage label Dec 24, 2024
@sfc-gh-sghosh
Copy link

Hello @AdamosX ,

Thanks for raising the issue. Could you clarify the requirement for the scenario and please share the code snippet as well?
Are you trying to convert JSON to custom python data types ?

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added the status-information_needed Additional information is required from the reporter label Dec 24, 2024
@AdamosX
Copy link
Author

AdamosX commented Dec 24, 2024

Sure, I just read a table schema from a real table on snowflake and serialized it to json.
Then I wanted to deserialize it from json, and it failed.

The code below contains the simplified relevant parts:

from snowflake.snowpark.types import StructType, TimestampType, TimestampTimeZone, StructField
s = StructType(
        [
            StructField(
                "INSERT_TIMESTAMP",
                TimestampType(timezone=TimestampTimeZone.NTZ), #if I remove timezone, it works
                nullable=True,
            ),
        ]
    )
j = s.json_value()
sj = StructType.from_json(j) #does not work: ValueError: Cannot parse data type: timestamp_ntz

@sfc-gh-sghosh
Copy link

Thank you @AdamosX ,

We are able to reproduce the issue, and will work on eliminating it, and will update.

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added status-triage_done Initial triage done, will be further handled by the driver team bug Something isn't working and removed status-information_needed Additional information is required from the reporter status-triage Issue is under initial triage labels Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants