-
Notifications
You must be signed in to change notification settings - Fork 186
[FLINK-37809][Connector/JDBC] sqlserver limit statement support #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,7 +179,7 @@ public ScanRuntimeProvider getScanRuntimeProvider(ScanContext runtimeProviderCon | |
} | ||
|
||
if (limit >= 0) { | ||
query = String.format("%s %s", query, dialect.getLimitClause(limit)); | ||
query = dialect.addLimitClause(query, limit); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find it confusing that we have a Why did we not just extend the getLimitClause to include the query and limit as parameters. Then the dialect can return the limit clause as it likes . And change this calling line to: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The initial plan would be to deprecate the getLimitClause method in the interface and keep it only in the AbstractDialect. This way, we don't have to update all dialects or duplicate code between them. Currently, getLimitClause is responsible for returning the part of the query that handles the limit. Previously, adding this to the query was done in JdbcDynamicTableSource, but now it has been moved to addLimitClause in AbstractDialect, which always adds the limit at the end of the query. However, in this case, the limit needs to be added at the beginning/middle of the query. If the problem is with the method name, I don't see an issue with keeping it the same as before. However, it does seem a bit odd to have a get method that modifies a parameter passed to it. Would you like to revisit the method naming or reconsider the overall approach? |
||
} | ||
|
||
LOG.debug("Query generated for JDBC scan: " + query); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,4 +91,11 @@ void testSelectStatement() { | |
"SELECT id, name, email, ts, field1, field_2, __field_3__ FROM tbl " | ||
+ "WHERE id = :id AND __field_3__ = :__field_3__"); | ||
} | ||
|
||
@Test | ||
void testLimitStatement() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have a limit test for all dialects using the JdbcITCase. |
||
String selectStmt = dialect.addLimitClause("SELECT * FROM TBL", 10); | ||
assertThat(selectStmt) | ||
.isEqualTo("SELECT TOP 10 * FROM TBL"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand this sentence.