Skip to content
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

Simplify SQL Server limit function #6676

Conversation

findepi
Copy link
Member

@findepi findepi commented Jan 21, 2021

extracted from #6667, for #6620

Some databases require columns to be named under some conditions. For
example, SQL Servers require this in subqueries.
Remove editing of the query, by putting the original query in a
subquery.
checkArgument(sql.startsWith(start));
return "SELECT TOP " + limit + " " + sql.substring(start.length());
});
return Optional.of((sql, limit) -> format("SELECT TOP %s * FROM (%s) o", limit, sql));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : Since limit is a long , so can we provide proper format specifier for the same ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i use (we use?) %s for simplicity, unless i want to have type-specific formatting.

@findepi
Copy link
Member Author

findepi commented Jan 22, 2021

CI #6646

@findepi findepi merged commit bb7ef11 into trinodb:master Jan 22, 2021
@findepi findepi deleted the findepi/simplify-sql-server-limit-function-8a71c7 branch January 22, 2021 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants