-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix bad parameter count in code generator #7014
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
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 |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |
| import org.testng.annotations.Test; | ||
|
|
||
| import java.net.URI; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.function.Function; | ||
|
|
@@ -257,25 +258,21 @@ public void testVersionOnError() | |
| @Test | ||
| public void testVersionOnCompilerFailedError() | ||
| { | ||
| int numberColumns = 170; | ||
| String tableName = "memory.default.test_version_on_compiler_failed"; | ||
| try (TestingTrinoClient testingClient = new TestingTrinoClient(server, testSessionBuilder().build())) { | ||
| testingClient.execute("DROP TABLE IF EXISTS " + tableName); | ||
| testingClient.execute("CREATE TABLE " + tableName + " AS SELECT " + | ||
| IntStream.range(0, numberColumns) | ||
| .mapToObj(columnNumber -> format("'' AS f%s", columnNumber)) | ||
| .collect(joining(", "))); | ||
|
|
||
| String pivotQuery = "SELECT x, y " + | ||
| "FROM " + tableName + " " + | ||
| "CROSS JOIN UNNEST(" + | ||
| IntStream.range(0, numberColumns) | ||
| .mapToObj(Integer::toString) | ||
| .collect(joining(", ", "ARRAY[", "]")) + "," + | ||
| IntStream.range(0, numberColumns) | ||
| .mapToObj(columnNumber -> format("f%s", columnNumber)) | ||
| .collect(joining(", ", "ARRAY[", "]")) + ") t(x, y)"; | ||
| checkVersionOnError(pivotQuery, "TrinoException: Compiler failed(?s:.*)at io.trino.sql.gen.PageFunctionCompiler.compileProjection"); | ||
| testingClient.execute("CREATE TABLE " + tableName + " AS SELECT '' as foo"); | ||
|
|
||
| // This query is designed to cause a compile failure, and hopefully not run too long. | ||
| // The exact query is not important, just that it causes a failure. | ||
|
||
| String array = IntStream.range(0, 254) | ||
| .mapToObj(columnNumber -> "foo") | ||
| .collect(joining(", ", "ARRAY[", "]")); | ||
| String query = "SELECT " + | ||
| String.join(" || ", Collections.nCopies(10, array)) + | ||
| "FROM " + tableName; | ||
|
|
||
| checkVersionOnError(query, "TrinoException: Compiler failed(?s:.*)at io.trino.sql.gen.ExpressionCompiler.compile"); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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 guess the query can select from VALUES and thus you don't need to DROP and CREATE here
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.
Using values is dangerous as it can be optimized away. I'm just going to leave the query as is.