-
Notifications
You must be signed in to change notification settings - Fork 4
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
test for wrong table #48
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: dbulahov <[email protected]>
Good test. Really important to also resolve all nested select Statements |
@@ -34,6 +34,8 @@ | |||
import org.junit.jupiter.api.Test; | |||
import org.junit.jupiter.params.provider.Arguments; | |||
|
|||
import static org.junit.jupiter.api.Assertions.assertThrowsExactly; |
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.
Please avoid those static imports.
.addTable("a", new JdbcColumn("col1"), new JdbcColumn("col2"), new JdbcColumn("col3")) | ||
.addTable("b", new JdbcColumn("col1"), new JdbcColumn("col2"), new JdbcColumn("col3")); | ||
|
||
//should be exception bb table not exist |
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.
This does not check for a specific exception.
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.
Please fix format exceptions.
Please check for the specific exception which returns "BB", not just any exception.
Signed-off-by: dbulahov <[email protected]>
Signed-off-by: dbulahov <[email protected]>
Signed-off-by: dbulahov <[email protected]>
Signed-off-by: dbulahov <[email protected]>
} | ||
|
||
@Test | ||
void testWithWrongColumn() { |
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.
This will not throw any exception because foo.name1
is not related to any SelectItem
and not part of the lineage.
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.
we throw exception if we use "wrong" name of column. But why "wrong" table name should have other behavior
|
||
//should be exception because foo1 table is not exist | ||
org.junit.jupiter.api.Assertions.assertThrows(JSQLParserException.class, () -> JSQLColumResolver.getResultSetMetaData("select sum(foo1.id) from foo group by foo.name", metaData)); | ||
org.junit.jupiter.api.Assertions.assertThrows(JSQLParserException.class, () -> JSQLColumResolver.getResultSetMetaData("select avg(foo1.id) from foo group by foo.name", metaData)); |
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.
Literally the same tests.
.addTable("foo", new JdbcColumn("id"), new JdbcColumn("name")); | ||
|
||
//should be exception because foo1 table is not exist | ||
org.junit.jupiter.api.Assertions.assertThrows(JSQLParserException.class, () -> JSQLColumResolver.getResultSetMetaData("select sum(foo1.id) from foo group by foo.name", metaData)); |
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.
Please:
import org.junit.jupiter.api.Assertions
and then call Assertions.assertThrows(...)
.addTable("b", new JdbcColumn("col1"), new JdbcColumn("col2"), new JdbcColumn("col3")); | ||
|
||
//should be exception because bb table is not exist | ||
org.junit.jupiter.api.Assertions.assertThrows(JSQLParserException.class, () -> JSQLColumResolver.getResultSetMetaData("select * from a where a.col1 in (select bb.col1 from bb)", metaData)); |
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.
JSQLParserException
is very generic and can mean anything.
If you want to make this test meaniningful then please check if Table bb
is pointed out and blamed correctly.
Pritty relevant that we can resolve any column in the Statement or an inner statement in from section or functions or elsewhere |
Should we have a meeting on that? I teally would like to have this part in. And if we need a common Unserstanding of what we expect , a discussion may help. |
That's a good idea. I can offer a time slot for Friday or Saturday between 7 AM and 3 PM GMT. Please do let me know if this suits you. |
Friday 7.00 GMT Also okay for you? |
Join Zoom Meeting Meeting ID: 943 6090 6149 |
some usecases
|
Greetings @stbischof and thank you for the examples. All of those can be covered (only) when we extended the scope of lineage/resolution to the full AST. At the moment, by design, only |
Will contact you in next days. |
Signed-off-by: dbulahov [email protected]