aminghadersohi opened a new pull request, #44708:
URL: https://github.com/apache/superset/pull/44708
### SUMMARY
sqlglot 30.18 (the minimum in `pyproject.toml`) calls
`_parse_term(parse_mod=False)` while parsing `LIMIT`/`OFFSET`. The DB2
dialect's `Parser._parse_term` override has no such parameter, so parsing any
DB2 statement with a `LIMIT` fails:
```python
>>> SQLScript("SELECT * FROM t LIMIT 10 OFFSET 2", "db2")
TypeError: DB2.Parser._parse_term() got an unexpected keyword argument
'parse_mod'
```
SQL Lab applies a `LIMIT` to every query, so on DB2 every SQL Lab query
failed with this error before reaching the database.
The override also only handled `+` and `-`, so sqlglot's other term
operators (e.g. `COLLATE`) were no longer parsed.
This change follows sqlglot's own `_parse_term` loop (forwarding `parse_mod`
and handling every `TERM` operator) and keeps the DB2 labeled-duration handling
(`expr + 1 DAYS`) on top of it.
### BEFORE/AFTER
Against a local DB2 LUW 11.5.9.0 server, running
`sql_lab.execute_sql_statements` for a simple `SELECT`:
- Before: `TypeError: DB2.Parser._parse_term() got an unexpected keyword
argument 'parse_mod'`
- After: the query runs and returns its rows.
### TESTING INSTRUCTIONS
`pytest tests/unit_tests/sql/dialects/db2_tests.py` — new cases for
`LIMIT`/`OFFSET`, a subquery with `LIMIT`, `%` with `LIMIT`, and `COLLATE`: 4
failed before, 28 passed after. Existing labeled-duration tests are unchanged
and pass.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]