First of all - I am unsure how to turn this into a reproducible example as my issue is the connection to snowflake
What I am attempting to do: Write a (JSON) string generated within python to a Snowflake VARIANT column (using the output tool). Note: On my local machine, I use python to write the data to snowflake (using the snowflake.connector library) however this is not available to me on the server due to authentication requirements.
Method:
(1) The python code contains the following:
df_out = df_in[cols1]
df_out['FEATURES'] = df_in[cols2].apply(lambda x: x.to_json(), axis=1)
(2) Python Output #1: Pandas dataframe (df_out) with example value within the Features column as follows
{"X1":0.1304007565,"X2":0.0,"X3":0.0,"X5":0.233,"Z":0}
(3) Output Data tool:
The Snowflake table SANDPIT.CUST_BH_SEG.MODEL_TAGS_20210914 has a column FEATURES which is type VARIANT.
The following image shows how it is configured.
This is the error message I receive: Error: Output Data (73): Error SQLPrepare: SQL compilation error:
Expression type does not match column data type, expecting VARIANT but got VARCHAR(2) for column FEATURES
Any advice on how to configure this Alteryx flow so that I can write the data to Snowflake would be much appreciated !
EDIT: Note as a work-around, I have done the following:
INSERT INTO SANDPIT.CUST_BH_SEG.MODEL_TAGS_20210914 (..., FEATURES)
SELECT ...,TO_VARIANT(FEATURES)
FROM MY_INT_TABLE;