snowflakedb / snowflakedb/snowpark-python

SNOW-1234800 SNOW-939204 : Converting Structured and Semi-Structured Types with cast()

Open
#1,314 5 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug status-triage_done
Dominant language
Python
Stars
341
Forks
155
Avg merge
4d 16h
Merged PRs (30d)
27

Description

Is there any example of converting Structured and Semi-Structured types with Column cast()
e.g., how to convert the following SQL to Snowpark

select CAST (UNSTRCUTURED_ARRAY AS ARRAY(VARCHAR)) AS STRCUTURED_ARRAY ;

What is the current behavior?

from snowflake.snowpark import functions as F
from snowflake.snowpark import types as T

df.filter(F.array_contains(F.lit('Key'), F.expr('CAST (KEY_UNSTRCUTURED_ARRAY AS ARRAY(VARCHAR))'))).show()

What is the desired behavior?

df.filter(F.array_contains(F.lit('Key'), F.col('KEY_UNSTRCUTURED_ARRAY ').cast('ARRAY(VARCHAR)')).show()
# or
df.filter(F.array_contains(F.lit('Key'), F.col('KEY_UNSTRCUTURED_ARRAY ').cast(T.ArraryType(T.StringType()))).show()

How would this improve snowflake-snowpark-python?

References, Other Background

Converting Structured and Semi-Structured Types
https://docs.snowflake.com/en/sql-reference/data-types-structured#label-structured-types-casting

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.