You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "BenSatori (via GitHub)" <gi...@apache.org> on 2026/09/14 13:16:10 UTC
[PR] Postgres: Support IS DOCUMENT predicate [datafusion-sqlparser-rs]
BenSatori opened a new pull request, #2508:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2508
Adds parsing and round-tripping for PostgreSQL XML `IS DOCUMENT` and `IS NOT DOCUMENT` predicates.
PostgreSQL documents these under XML predicates: https://www.postgresql.org/docs/current/functions-xml.html#FUNCTIONS-XML-PREDICATES
The parser handles `DOCUMENT` contextually after `IS`, gated by the existing XML expression dialect capability, so it does not become a global keyword.
AI assistance was used in preparing this change.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Postgres: Support IS DOCUMENT predicate [datafusion-sqlparser-rs]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2508:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2508#issuecomment-5803876409
## [Codecov](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2508?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `96.15385%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 80.97%. Comparing base ([`9ae00e7`](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/commit/9ae00e73b54ebbca2341c3de22312a8011e98757?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`049c7ab`](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/commit/049c7ab560919b4b9ebc96bca544dd8ec27433d9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2508?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [src/ast/spans.rs](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2508?src=pr&el=tree&filepath=src%2Fast%2Fspans.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL2FzdC9zcGFucy5ycw==) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2508?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #2508 +/- ##
==========================================
+ Coverage 80.96% 80.97% +0.01%
==========================================
Files 42 42
Lines 33359 33384 +25
Branches 33359 33384 +25
==========================================
+ Hits 27009 27033 +24
- Misses 2790 2791 +1
Partials 3560 3560
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion-sqlparser-rs/pull/2508?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Postgres: Support IS DOCUMENT predicate [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on code in PR #2508:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2508#discussion_r4095602599
##########
src/parser/mod.rs:
##########
@@ -4091,6 +4091,15 @@ impl<'a> Parser<'a> {
Ok(Expr::IsUnknown(Box::new(expr)))
} else if self.parse_keywords(&[Keyword::NOT, Keyword::UNKNOWN]) {
Ok(Expr::IsNotUnknown(Box::new(expr)))
+ } else if let Some(negated) = if dialect.supports_xml_expressions() {
+ self.parse_is_document_predicate()
+ } else {
+ None
+ } {
+ Ok(Expr::IsDocument {
+ expr: Box::new(expr),
+ negated,
+ })
Review Comment:
You should match `DOCUMENT` as a keyword with `parse_keyword`/`parse_keywords`, like the neighbouring `UNKNOWN` and `JSON` arms. Ofc add the `keywords.rs` entry.
```suggestion
} else if dialect.supports_xml_expressions()
&& self.parse_keyword(Keyword::DOCUMENT)
{
Ok(Expr::IsDocument {
expr: Box::new(expr),
negated: false,
})
} else if dialect.supports_xml_expressions()
&& self.parse_keywords(&[Keyword::NOT, Keyword::DOCUMENT])
{
Ok(Expr::IsDocument {
expr: Box::new(expr),
negated: true,
})
```
##########
src/parser/mod.rs:
##########
@@ -4752,6 +4761,16 @@ impl<'a> Parser<'a> {
}
}
+ fn parse_unquoted_word(&mut self, expected: &str) -> bool {
+ match &self.peek_token_ref().token {
+ Token::Word(w) if w.quote_style.is_none() && w.value.eq_ignore_ascii_case(expected) => {
+ self.advance_token();
+ true
+ }
+ _ => false,
+ }
+ }
+
Review Comment:
You could drop `parse_unquoted_word`, since `parse_keyword(Keyword::DOCUMENT)` covers it. The tokenizer already gives quoted words `Keyword::NoKeyword`.
```suggestion
```
##########
src/parser/mod.rs:
##########
@@ -4109,7 +4118,7 @@ impl<'a> Parser<'a> {
Ok(is_normalized)
} else {
self.expected_ref(
- "[NOT] NULL | TRUE | FALSE | DISTINCT | [NOT] JSON [VALUE | SCALAR | ARRAY | OBJECT] [WITH | WITHOUT UNIQUE [KEYS]] | [form] NORMALIZED FROM after IS",
+ "[NOT] NULL | TRUE | FALSE | DISTINCT | [NOT] DOCUMENT | [NOT] JSON [VALUE | SCALAR | ARRAY | OBJECT] [WITH | WITHOUT UNIQUE [KEYS]] | [form] NORMALIZED FROM after IS",
Review Comment:
You should keep `[NOT] DOCUMENT` out of this message, which every dialect shares.
```suggestion
"[NOT] NULL | TRUE | FALSE | DISTINCT | [NOT] JSON [VALUE | SCALAR | ARRAY | OBJECT] [WITH | WITHOUT UNIQUE [KEYS]] | [form] NORMALIZED FROM after IS",
```
##########
src/parser/mod.rs:
##########
@@ -12742,6 +12761,20 @@ impl<'a> Parser<'a> {
})
}
+ fn parse_is_document_predicate(&mut self) -> Option<bool> {
+ if self.parse_unquoted_word("document") {
+ return Some(false);
+ }
+
+ let start_index = self.index;
+ if self.parse_keyword(Keyword::NOT) && self.parse_unquoted_word("document") {
+ Some(true)
+ } else {
+ self.index = start_index;
+ None
+ }
+ }
+
Review Comment:
You could drop `parse_is_document_predicate` along with the manual `self.index` rewind, since `parse_keywords` handles both.
```suggestion
```
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org