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 · 2 comments
Assignees
Labels
status-information_needed Additional information is required from the reporter status-triage Issue is under initial triage

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status-information_needed Additional information is required from the reporter status-triage Issue is under initial triage
Projects
None yet
Development

No branches or pull requests

2 participants