Skip to content

Simplify SQL Server limit function#6676

Merged
findepi merged 2 commits intotrinodb:masterfrom
findepi:findepi/simplify-sql-server-limit-function-8a71c7
Jan 22, 2021
Merged

Simplify SQL Server limit function#6676
findepi merged 2 commits intotrinodb:masterfrom
findepi:findepi/simplify-sql-server-limit-function-8a71c7

Conversation

@findepi
Copy link
Copy Markdown
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.
@findepi findepi requested review from kokosing and losipiuk January 21, 2021 11:26
@cla-bot cla-bot bot added the cla-signed label Jan 21, 2021
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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