GoodNight830 opened a new issue, #6011:
URL: https://github.com/apache/seatunnel/issues/6011

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   When using SQL server for data synchronization, the time type in the 
database is datatime2, at this time, when I operate, I add the condition of the 
time field to the sql statement, and there is a Filed types not matched, left 
is: LocalDateTime, right is: String error, but I don't add single quotation 
marks to the date field, and SQL server can't recognize the statement
   
   
   
   ### SeaTunnel Version
   
   2.3.3
   
   ### SeaTunnel Config
   
   ```conf
   sqlserver
   ```
   
   
   ### Running Command
   
   ```shell
   {
        "env": {
                "execution.parallelism": "1",
                "job.mode": "BATCH",
                "checkpoint.interval": "10000",
                "execution.checkpoint.interval": "10000"
        },
        "source": [
                {
                        "tableInfo": {
                                "columnName": "create_time",
                                "dataType": 93
                        },
                        "password": "Rr.123456",
                        "driver": 
"com.microsoft.sqlserver.jdbc.SQLServerDriver",
                        "query": "select * from sfm_user  where create_time >= 
'2023-12-11T10:58:24.844' and create_time <= '2023-12-16T10:58:24.844' order by 
create_time asc",
                        "result_table_name": "switch_sfm_user",
                        "plugin_name": "Jdbc",
                        "user": "sa",
                        "url": 
"jdbc:sqlserver://xxx.xxx.x.xxx:1433;DatabaseName=testdb;encrypt=false"
                }
        ],
        "transform": [
                {
                        "tableInfo": {
                                "columnName": "create_time",
                                "dataType": 93
                        },
                        "driver": 
"com.microsoft.sqlserver.jdbc.SQLServerDriver",
                        "query": "select * from switch_sfm_user  where 
create_time >= CONVERT(datetime2, DATEADD(MILLISECOND, 1702436304743 / 1000, 
'19700101')) and  create_time <= '2023-12-16T10:58:24.844' ",
                        "source_table_name": "switch_sfm_user",
                        "result_table_name": "sfm_user",
                        "plugin_name": "Sql"
                }
        ],
        "sink": [
                {
                        "password": "Rr.123456",
                        "database": "testdb",
                        "driver": 
"com.microsoft.sqlserver.jdbc.SQLServerDriver",
                        "query": "MERGE INTO sfm_user AS target USING (VALUES 
(?,?,?)) AS source (id,name,create_time) ON target.id = source.id WHEN MATCHED 
THEN     UPDATE SET 
target.id=source.id,target.name=source.name,target.create_time=source.create_timeWHEN
 NOT MATCHED THEN     INSERT (id,name,create_time) VALUES 
(source.id,source.name,source.create_time);",
                        "source_table_name": "sfm_user",
                        "plugin_name": "Jdbc",
                        "user": "sa",
                        "url": 
"jdbc:sqlserver://xxx.xxx.x.xxx:1433;DatabaseName=testdb;encrypt=false"
                }
        ]
   }
   ```
   
   
   ### Error Exception
   
   ```log
   Filed types not matched, left is: LocalDateTime, right is: String 
           at 
org.apache.seatunnel.transform.sql.zeta.ZetaSQLFilter.greaterThanEqualsExpr(ZetaSQLFilter.java:265)
           at 
org.apache.seatunnel.transform.sql.zeta.ZetaSQLFilter.executeFilter(ZetaSQLFilter.java:84)
           at 
org.apache.seatunnel.transform.sql.zeta.ZetaSQLFilter.andExpr(ZetaSQLFilter.java:330)
           at 
org.apache.seatunnel.transform.sql.zeta.ZetaSQLFilter.executeFilter(ZetaSQLFilter.java:94)
           at 
org.apache.seatunnel.transform.sql.zeta.ZetaSQLEngine.transformBySQL(ZetaSQLEngine.java:222)
           at 
org.apache.seatunnel.transform.sql.SQLTransform.transformRow(SQLTransform.java:140)
           at 
org.apache.seatunnel.transform.common.AbstractSeaTunnelTransform.map(AbstractSeaTunnelTransform.java:80)
           at 
org.apache.seatunnel.transform.common.AbstractSeaTunnelTransform.map(AbstractSeaTunnelTransform.java:32)
           at 
org.apache.seatunnel.engine.server.task.flow.TransformFlowLifeCycle.received(TransformFlowLifeCycle.java:94)
           at 
org.apache.seatunnel.engine.server.task.flow.TransformFlowLifeCycle.received(TransformFlowLifeCycle.java:37)
           at 
org.apache.seatunnel.engine.server.task.SeaTunnelSourceCollector.sendRecordToNext(SeaTunnelSourceCollector.java:139)
           at 
org.apache.seatunnel.engine.server.task.SeaTunnelSourceCollector.collect(SeaTunnelSourceCollector.java:67)
           at 
org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceReader.pollNext(JdbcSourceReader.java:64)
           at 
org.apache.seatunnel.engine.server.task.flow.SourceFlowLifeCycle.collect(SourceFlowLifeCycle.java:150)
           at 
org.apache.seatunnel.engine.server.task.SourceSeaTunnelTask.collect(SourceSeaTunnelTask.java:95)
           at 
org.apache.seatunnel.engine.server.task.SeaTunnelTask.stateProcess(SeaTunnelTask.java:168)
           at 
org.apache.seatunnel.engine.server.task.SourceSeaTunnelTask.call(SourceSeaTunnelTask.java:100)
           at 
org.apache.seatunnel.engine.server.TaskExecutionService$BlockingWorker.run(TaskExecutionService.java:613)
           at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
           at java.util.concurrent.FutureTask.run(FutureTask.java:266)
           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:750)
   
   
   
   
   023-12-14 14:00:00,867 WARN  
org.apache.seatunnel.api.configuration.util.ConfigUtil - Option 
'source_table_name' is a List, and it is recommended to configure it as 
["string1","string2"]; we will only use ',' to split the String into a list.
   2023-12-14 14:00:00,868 WARN  
org.apache.seatunnel.api.configuration.util.ConfigUtil - Option 
'source_table_name' is a List, and it is recommended to configure it as 
["string1","string2"]; we will only use ',' to split the String into a list.
   2023-12-14 14:00:00,873 WARN  
org.apache.seatunnel.engine.server.log.Log4j2HttpPostCommandProcessor - 
[localhost]:5801 [seatunnel] [5.1] An error occurred while handling request 
HttpCommand 
[HTTP_POST]{uri='/hazelcast/rest/maps/submit-job?jobId=1'}AbstractTextCommand[HTTP_POST]{requestId=0}
   org.apache.seatunnel.transform.exception.TransformException: 
ErrorCode:[COMMON-05], ErrorDescription:[Unsupported operation] - SQL parse 
failed: select * from switch_sfm_user  where create_time >= 
2024-02-09T10:58:24.844 and  create_time <= 2024-02-09T10:58:24.844 , cause: 
net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "T10" 
<S_IDENTIFIER>
       at line 1, column 63.
   
   Was expecting one of:
   
       "&"
       "::"
       ";"
       "<<"
       ">>"
       "COLLATE"
       "CONNECT"
       "EMIT"
       "GROUP"
       "HAVING"
       "START"
       "["
       "^"
       "|"
       <EOF>
   ```
   
   
   ### Zeta or Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   1.8
   
   ### Screenshots
   
   
![image](https://github.com/apache/seatunnel/assets/61530277/6ab12968-38bc-45c8-8d20-235a4732aefb)
   
   
   
![image](https://github.com/apache/seatunnel/assets/61530277/f67909de-7386-43ff-9f1c-0660948e05d2)
   
   In the java code I've made sure that the type is converted to localdatatime
   
   
![image](https://github.com/apache/seatunnel/assets/61530277/3a6f2357-ac8f-4983-8ba6-7e752212635a)
   
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@seatunnel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to