You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following test fails with a NullPointerException when added to the KQLParserTest.java class:
@Test
public void testMultipleJoins() throws Exception {
MetaStore tempMetaStore = new MetaStoreImpl();
for (KQLTopic kqlTopic : metaStore.getAllKQLTopics().values()) {
tempMetaStore.putTopic(kqlTopic);
}
for (StructuredDataSource dataSource : metaStore.getAllStructuredDataSources().values()) {
tempMetaStore.putSource(dataSource);
}
SchemaBuilder schemaBuilder = SchemaBuilder.struct()
.field("COL0", SchemaBuilder.INT64_SCHEMA)
.field("COL1", SchemaBuilder.FLOAT64_SCHEMA)
.field("COL2", SchemaBuilder.STRING_SCHEMA)
.field("COL3", SchemaBuilder.INT64_SCHEMA);
KQLTopic
kqlTopic =
new KQLTopic("TEST3", "test3", new KQLJsonTopicSerDe());
KQLStream kqlStream = new KQLStream("TEST3", schemaBuilder, schemaBuilder.field("COL0"),
kqlTopic);
tempMetaStore.putTopic(kqlTopic);
tempMetaStore.putSource(kqlStream);
String
queryStr =
"SELECT t1.col1, t2.col2, t3.col3 FROM "
+ "(test1 t1 LEFT JOIN test2 t2 ON t1.col1 = t2.col1) "
+ "LEFT JOIN test3 t3 ON t1.col1 = t3.col1;";
Statement statement = kqlParser.buildAST(queryStr, tempMetaStore).get(0);
Assert.assertTrue("testSimpleQuery fails", statement instanceof Query);
Query query = (Query) statement;
Assert.assertTrue("testTripleJoin fails", query.getQueryBody() instanceof QuerySpecification);
}
The problem appears to be in the DataSourceExtractor.visitAliasedRelation() method, where it is assumed that the relationPrimary component of an aliasedRelation rule is a qualifiedName, when in fact it can also be another relation contained between parentheses, like in (test1 t1 LEFT JOIN test2 t2 ON t1.col1 = t2.col1). The result is that this relationPrimary is then visited as a joinRelation, which causes the visitJoinRelation() method to be called, which then returns null all the way up the call chain back to the original invocation of visitAliasedRelation, which then causes the NPE when the result (assumed to be a Table, actually null) is accessed.
The text was updated successfully, but these errors were encountered:
The following test fails with a NullPointerException when added to the KQLParserTest.java class:
The problem appears to be in the DataSourceExtractor.visitAliasedRelation() method, where it is assumed that the
relationPrimary
component of analiasedRelation
rule is aqualifiedName
, when in fact it can also be anotherrelation
contained between parentheses, like in(test1 t1 LEFT JOIN test2 t2 ON t1.col1 = t2.col1)
. The result is that thisrelationPrimary
is then visited as ajoinRelation
, which causes the visitJoinRelation() method to be called, which then returnsnull
all the way up the call chain back to the original invocation ofvisitAliasedRelation
, which then causes the NPE when the result (assumed to be aTable
, actuallynull
) is accessed.The text was updated successfully, but these errors were encountered: