Sleepy0521 commented on PR #160:
URL: 
https://github.com/apache/flink-connector-jdbc/pull/160#issuecomment-2785564098

   
   
   
   > I am not sure this is a hotfix, please could you raise a Jira explaining
   > 
   > * what the current issue with SQL Server is
   > * why this is not being solved in the dialect. I do not think that 
JdbcDynamicTablesource should have any reference to a specific dialect. Would 
it be more appropriate to use the Select TOP for all dialect?
   > * if the SQL Server issue was not causing a unit test failure - we need to 
add a unit test in this area.
   
   I applied for a Jira account but it hasn't been approved yet. 
   
   - The problem occurs when you use the SQL Server JDBC connector to query a 
SQL Server table. If you don't add a LIMIT statement or any WHERE clause, the 
Flink connector will query the entire table, which can impose IO pressure on 
the SQL Server. 
   - For simple queries or tests where you only need to retrieve a few hundred 
records, using the LIMIT statement would be more efficient. However, Flink 
sqlserver connector does not support this feature. SqlServerDialect.java
   
   ```java
       
       @Override
       public String getLimitClause(long limit) {
           throw new IllegalArgumentException("SqlServerDialect does not 
support limit clause");
       }
   ```
   -  why this is not being solved in the dialect. The JdbcDynamicTableSource 
directly appends the LIMIT statement at the end of the query, even though SQL 
Server clearly does not support this syntax. so, I added an if-else block in 
JdbcDynamicTableSource
   ```java
       if (limit >= 0) {
           query = String.format("%s %s", query, dialect.getLimitClause(limit));
       }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to