adriangb commented on code in PR #2458:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2458#discussion_r3862753588


##########
tests/sqlparser_derive_dialect.rs:
##########
@@ -121,3 +123,45 @@ fn test_identifier_quote_style_overrides() {
         None
     );
 }
+
+#[test]
+fn test_lambda_keyword_syntax_on_postgres_derivative() {
+    // A PostgreSQL derivative can opt into the `LAMBDA` keyword spelling of
+    // lambda functions without giving up `->` as JSON member access.
+    derive_dialect!(
+        LambdaPostgreSqlDialect,
+        PostgreSqlDialect,
+        overrides = { supports_lambda_keyword_syntax = true }
+    );
+    let dialect = LambdaPostgreSqlDialect::new();
+
+    // Only the keyword spelling is enabled; the arrow spelling stays off.
+    assert!(dialect.supports_lambda_keyword_syntax());
+    assert!(!dialect.supports_lambda_functions());
+
+    // The `LAMBDA` spelling parses.
+    let sql = "SELECT transform(xs, lambda x : x + 1)";
+    let ast = Parser::parse_sql(&dialect, sql).unwrap();
+    assert_eq!(sql, ast[0].to_string());
+
+    // `->` and `->>` still parse as JSON member access rather than
+    // introducing a lambda parameter.
+    for (sql, expected_op) in [

Review Comment:
   Can these be in a single query, ideally something like `select transform(xs, 
lambda x: (x->'a')::int + 1)`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to