cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

SQL Server Merge Snap - Issues with Date as Null

gowdhaman008
New Contributor II

Hi,

I have developed the pipeline which reads the data from the incoming stream and send to SQL Merge. My pipeline looks like below.

image

My Input JSON is as follows:

[ {
โ€œmember_idโ€: 13000561,
โ€œintervention_idโ€: 1000034495,
โ€œsentimentโ€: null,
โ€œlast_updatedโ€: null,
โ€œincentive_offeredโ€: null,
โ€œreaction_detailsโ€: null,
โ€œdashboard_nameโ€: โ€œSalesForceโ€,
โ€œcreatedโ€: null,
โ€œintervention_assessmentโ€: null,
โ€œtactic_detailsโ€: null,
โ€œcreated_byโ€: null,
โ€œfollowup_deadlineโ€: {
โ€œ_snaptype_localdateโ€: โ€œ2019-10-13โ€
},
โ€œfollowupโ€: false,
โ€œlast_updated_byโ€: null,
โ€œcontact_methodโ€: null,
โ€œcontact_madeโ€: false,
โ€œdate_of_interventionโ€: null,
โ€œintervention_notesโ€: null
}]

Configuration for SQL Merge Snap:

image

Please note that we are allowing null for all the columns expect the intervention id which is the primary key. When we are running the pipeline, we are getting the following error.

{
โ€œerrorโ€: โ€œSQL operation failedโ€,
โ€œstacktraceโ€: โ€œjava.sql.BatchUpdateException: Implicit conversion from data type varbinary to date is not allowed. Use the CONVERT function to run this query.\n\tat com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:1178)\n\tat com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128)\n\tat com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)\n\tat org.jooq.tools.jdbc.DefaultStatement.executeBatch(DefaultStatement.java:93)\n\tat org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:239)\n\tat org.jooq.impl.BatchSingle.execute(BatchSingle.java:182)\n\tat com.snaplogic.snap.api.sql.operations.JdbcOperationsImpl.lambda$flushBatch$8(JdbcOperationsImpl.java:1547)\n\tat com.snaplogic.snap.api.sql.operations.JdbcOperationsImpl$$Lambda$394/1810556666.call(Unknown Source)\n\tat net.jodah.failsafe.Functions$11.call(Functions.java:263)\n\tat net.jodah.failsafe.SyncFailsafe.call(SyncFailsafe.java:145)\n\tat net.jodah.failsafe.SyncFailsafe.get(SyncFailsafe.java:69)\n\tat com.snaplogic.snap.api.sql.operations.JdbcOperationsImpl.flushBatch(JdbcOperationsImpl.java:1546)\n\tat com.snaplogic.snaps.sql.SimpleSqlWriteSnap.handle(SimpleSqlWriteSnap.java:136)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.callback(SnapRunnableImpl.java:836)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.executeForSuggest(SnapRunnableImpl.java:644)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:852)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.access$000(SnapRunnableImpl.java:118)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl$1.run(SnapRunnableImpl.java:392)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl$1.run(SnapRunnableImpl.java:388)\n\tat java.security.AccessController.doPrivileged(Native Method)\n\tat javax.security.auth.Subject.doAs(Subject.java:422)\n\tat org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:387)\n\tat com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:118)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\nโ€,
โ€œreasonโ€: โ€œImplicit conversion from data type varbinary to date is not allowed. Use the CONVERT function to run this query., error code: 257, SQL state: S0003โ€,
โ€œresolutionโ€: โ€œPlease check for valid Snap properties and input data.โ€,
โ€œstatus_codeโ€: โ€œerrorโ€,
โ€œstatusโ€: -3,
โ€œsnap_detailsโ€: {
โ€œlabelโ€: โ€œSQL Server - Mergeโ€,
โ€œinstance_idโ€: โ€œ7de1aaf6-483b-4e42-b1ed-46cf7f1fd2bdโ€,
โ€œclass_idโ€: โ€œcom-snaplogic-snaps-sqlserver-mergeโ€,
โ€œbuild_tagโ€: โ€œsnapsmrc523โ€,
โ€œviewsโ€: {
โ€œinโ€: {
โ€œinput0โ€: {
โ€œcountโ€: 2
}
},
โ€œoutโ€: {},
โ€œerrorโ€: {
โ€œerror0โ€: {
โ€œcountโ€: 0
}
}
}
},
โ€œoriginalโ€: {
โ€œmember_idโ€: 13000561,
โ€œintervention_idโ€: 1000034495,
โ€œsentimentโ€: null,
โ€œlast_updatedโ€: null,
โ€œincentive_offeredโ€: null,
โ€œreaction_detailsโ€: null,
โ€œdashboard_nameโ€: โ€œSalesForceโ€,
โ€œcreatedโ€: null,
โ€œintervention_assessmentโ€: null,
โ€œtactic_detailsโ€: null,
โ€œcreated_byโ€: null,
โ€œfollowup_deadlineโ€: {
โ€œ_snaptype_localdateโ€: โ€œ2019-10-13โ€
},
โ€œfollowupโ€: false,
โ€œlast_updated_byโ€: null,
โ€œcontact_methodโ€: null,
โ€œcontact_madeโ€: false,
โ€œdate_of_interventionโ€: null,
โ€œintervention_notesโ€: null
}
}

Please note that same thing works with the SQL Insert, but we are expecting the upsert to the table. Please help us resolving the issues.

Thanks,
Gowdhaman

2 REPLIES 2

anubhav_nautiya
Contributor

Seems like snaptype_localdate in your input is going as string, but the DB is expecting a date field, can you try to convert this to date and then pass it in the input to the DB.

Hi,

I have tried to cast as date type. But it still could not go with SQL merge, but note that it is working with SQL Inserts.

Thanks,
Gowdhaman