1
votes

Hello I am using below code for loading data from spark (pyspark) dataframe to snowflake table I am getting error like Timestamp '2020-06-15T12:00:20.040Z' is not recognized. please find below code for the same

sfOptionsRaw1 = { "sfURL" : "test", "sfUser" : "test", "sfPassword" : "test", "sfDatabase" : "test", "sfSchema" : "test", "sfWarehouse" : "test",
"sfrole" : "test", "TIMESTAMP_TYPE_MAPPING" : "TIMESTAMP_NTZ", "TIMESTAMP_NTZ_OUTPUT_FORMAT" : "YYYY-MM-DD HH24:MI:SS.FF3" }

test1.write.format(SNOWFLAKE_SOURCE_NAME).option("dbtable", "test").option("columnmap", "Map(type -> type_test1 )").options(**sfOptionsRaw1).mode("append").save()

After executing above cpde I get below error

Py4JJavaError: An error occurred while calling o2088.save. : net.snowflake.client.jdbc.SnowflakeSQLException: Timestamp '2020-06-15T12:00:20.040Z' is not recognized File 'NVefrmAwkn.csv', line 1, character 63 Row 1, column "_TEST1"["TIME_TEST1":4] If you would like to continue loading when an error is encountered, use other values such as 'SKIP_FILE' or 'CONTINUE' for the ON_ERROR option. For more information on loading options, please run 'info loading_data' in a SQL client. at net.snowflake.client.jdbc.SnowflakeUtil.checkErrorAndThrowException(SnowflakeUtil.java:102) at net.snowflake.client.core.StmtUtil.execute(StmtUtil.java:410) at net.snowflake.client.core.SFStatement.executeHelper(SFStatement.java:371) at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:195) at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:147) at net.snowflake.client.core.SFStatement.execute(SFStatement.java:529) at net.snowflake.client.jdbc.SnowflakeStatementV1.executeInternal(SnowflakeStatementV1.java:204) at net.snowflake.client.jdbc.SnowflakeStatementV1.execute(SnowflakeStatementV1.java:239) at net.snowflake.spark.snowflake.JDBCWrapper$$anonfun$executeInterruptibly$1.apply(SnowflakeJDBCWrapper.scala:261) at net.snowflake.spark.snowflake.JDBCWrapper$$anonfun$executeInterruptibly$1.apply(SnowflakeJDBCWrapper.scala:261) at net.snowflake.spark.snowflake.JDBCWrapper$$anonfun$3.apply(SnowflakeJDBCWrapper.scala:283) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

1

1 Answers

0
votes

Can you try changing the timestamp parameter to this:

"TIMESTAMP_NTZ_OUTPUT_FORMAT" : "YYYY-MM-DDTHH24:MI:SS.FF3Z"

This format matches the format that you are showing in your post, so it might fix your issue.