Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ public <S> T visit(PlainSelect plainSelect, S context) {
fromItemVisitor.visitTables(plainSelect.getIntoTables(), context);
fromItemVisitor.visitFromItem(plainSelect.getFromItem(), context);

// if (plainSelect.getLateralViews() != null) {
// //@todo: implement this
// }
if (plainSelect.getLateralViews() != null) {
for (LateralView lateralView : plainSelect.getLateralViews()) {
expressionVisitor.visitExpression(lateralView.getGeneratorFunction(), context);
}
}

fromItemVisitor.visitJoins(plainSelect.getJoins(), context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public <S> Void visit(PlainSelect plainSelect, S context) {
validateOptionalFromItem(plainSelect.getFromItem());
validateOptionalFromItems(plainSelect.getIntoTables());
validateOptionalJoins(plainSelect.getJoins());
if (isNotEmpty(plainSelect.getLateralViews())) {
plainSelect.getLateralViews()
.forEach(view -> validateOptionalExpression(view.getGeneratorFunction()));
}

// after the FROM items, to correctly recognize aliased tables
if (plainSelect.getDistinct() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,9 @@ private StatementFeatures analyseAllPureExcept(String sql, String impure)
"FROM t |> UNION ALL (SELECT pg_read_file('x'))",
"FROM t |> PIVOT (sum(pg_read_file('x')) FOR a IN (1))",
"FROM t |> WINDOW sum(pg_read_file('x')) OVER () AS w",
"SELECT * FROM (FROM t |> WHERE length(pg_read_file('x')) > 0)"})
"SELECT * FROM (FROM t |> WHERE length(pg_read_file('x')) > 0)",
"SELECT a FROM t LATERAL VIEW explode(pg_read_file('x')) v AS c",
"SELECT a FROM t LATERAL VIEW OUTER explode(pg_read_file('x')) v AS c"})
void functionIsChecked(String sql) throws JSQLParserException {
StatementFeatures impure = analyseAllPureExcept(sql, "pg_read_file");
assertThat(impure.getUnresolvedReferences()).containsExactly("pg_read_file");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ public void testValidateTableFunctionArguments(String sql) {
"SELECT a FROM t OFFSET upper(a) ROWS",
"SELECT a FROM t FETCH FIRST upper(a) ROWS ONLY",
"SELECT a FROM t UNION SELECT b FROM u LIMIT upper(a)",
"SELECT * FROM t PIVOT (max(upper(a)) FOR b IN (1))"})
"SELECT * FROM t PIVOT (max(upper(a)) FOR b IN (1))",
"SELECT a FROM t LATERAL VIEW explode(b) v AS c"})
public void testValidateFunctionOutsideWhere(String sql) {
validateNotAllowed(sql, 1, 1,
new FeaturesAllowed(Feature.values()).remove(Feature.function), Feature.function);
Expand Down
Loading