Closed oscarbonilla-tid closed 2 months ago
Greetings,
its largely supported since 5.0, the following query parses:
SELECT map_filter(my_column, v -> v.my_inner_column = 'some_value')
FROM my_table
However, I will need to look for extending the parameter syntax (x, y)
.
You're right. I've just tried parsing with just one parameter and that works.
In any case, I don't think Spark supports the use of that particular function (map_filter
) with just one parameter :(
@manticore-projects do you have plans to fix this in the near future? I can see you had the fix WIP in this commit https://github.com/JSQLParser/JSqlParser/commit/236793aaeabc30f80857b3347ce8e4a6b767e849#diff-d323df58a0300a038ac87b328bf05b8255ff06e6b5d0e9aeae641fa566e4068cR5214
Should be ready by the end of this week.
Sorry, I just checked the LambdaExpressionTest
and found:
@Disabled
@Test
// wip, right now the Grammar works but collides with Multi Value Lists
void testLambdaFunctionMultipleParameter() throws JSQLParserException {
String sqlStr = "SELECT list_transform(\n" +
" [1, 2, 3],\n" +
" x -> list_reduce([4, 5, 6], (a, b) -> a + b) + x\n" +
" )";
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
}
1) Multi-parameter Lambda expressions have been considered by design and should work in general
2) however, the Grammar collides will Multi Expression lists and needs to be refactored (which is a tedious process with lots of testing)
So I can not promise holding the time line.
Sorry for taking a bit longer. This try-hard example is parsing now:
SELECT list_transform(
[1, 2, 3],
x -> list_reduce([4, 5, 6], (a, b) -> a + b) + x
);
Thanks for the speed fixing it! Any timeline on a 5.1 release?
Thanks for the speed fixing it! Any timeline on a 5.1 release?
We just releases 5.0 and usual will have 4 releases per year, maybe less since JSQLParser has matured and there is not much stuff to do.
Also, releases have no big meaning here since our development is "test suite driven" and usually the latest snapshot is just the best version of the software.
And you are very welcome of course! Cheers!
Grammar or Syntax Description
Spark supports lambda expressions in some functions (e.g.
map_filter
). It is not possible to parse queries using such functionsSQL Example
Additional context