You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/16 15:53:32 UTC
(datafusion-sqlparser-rs) branch gh-readonly-queue/main/pr-2643-de737560d9e2cf5c7909269bcb4fdf44f58d4774 created (now f88f6850)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-2643-de737560d9e2cf5c7909269bcb4fdf44f58d4774
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
at f88f6850 Parser: Fix array suffixes after a `>>` that closes two nested types (#2643)
This branch includes the following new commits:
new f88f6850 Parser: Fix array suffixes after a `>>` that closes two nested types (#2643)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org
(datafusion-sqlparser-rs) 01/01: Parser: Fix array suffixes after a `>>` that closes two nested types (#2643)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-2643-de737560d9e2cf5c7909269bcb4fdf44f58d4774
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit f88f6850717f8665b9228b2d29d3d08831cdceb1
Author: Koen Denecker <ko...@polars.tech>
AuthorDate: Fri Oct 16 15:53:08 2026 +0000
Parser: Fix array suffixes after a `>>` that closes two nested types (#2643)
---
src/parser/mod.rs | 5 +++++
tests/sqlparser_common.rs | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 24947764..4e2fee94 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -13411,6 +13411,11 @@ impl<'a> Parser<'a> {
_ => self.expected_at("a data type name", next_token_index),
}?;
+ // The `>>` that closed this type also closed the enclosing one, so any suffix belongs to that.
+ if trailing_bracket.0 {
+ return Ok((data, trailing_bracket));
+ }
+
if self.is_zerofill_allowed(next_token_index) && self.parse_keyword(Keyword::ZEROFILL) {
data = DataType::Zerofill(Box::new(data));
}
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index abb9ac9c..8b7a51e1 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -20607,3 +20607,39 @@ fn parse_position_in_connect_by_list_after_state_change() {
assert_eq!(positions, 1, "{dialect:?}");
}
}
+
+#[test]
+fn parse_array_suffix_after_nested_type() {
+ // When `>>` closes two types at once, a following array suffix belongs to the outer one.
+ let dialects = all_dialects_where(|d| {
+ d.supports_struct_literal() && d.supports_array_typedef_with_brackets()
+ });
+ dialects.verified_stmt("SELECT CAST(NULL AS STRUCT<a STRUCT<b INT>>[])");
+ dialects.verified_stmt("SELECT CAST(NULL AS STRUCT<a STRUCT<b INT>[]>)");
+ dialects.verified_stmt("SELECT CAST(NULL AS STRUCT<a STRUCT<b STRUCT<c INT>>>[])");
+ dialects.verified_stmt("SELECT CAST(NULL AS STRUCT<a STRUCT<b INT>>[][2])");
+ dialects.verified_stmt("SELECT CAST(NULL AS ARRAY<ARRAY<INT>>[])");
+ dialects.verified_stmt("SELECT CAST(NULL AS ARRAY<STRUCT<a INT>>[])");
+ assert_eq!(
+ dialects.parse_sql_statements("SELECT CAST(NULL AS STRUCT<a STRUCT<b INT>>[)"),
+ Err(ParserError::ParserError(
+ "Expected: ], found: )".to_string()
+ ))
+ );
+ assert_eq!(
+ dialects.parse_sql_statements("SELECT CAST(NULL AS STRUCT<a STRUCT<b INT>>[x])"),
+ Err(ParserError::ParserError(
+ "Expected: ], found: x".to_string()
+ ))
+ );
+
+ let dialects = all_dialects_where(|d| d.supports_struct_literal());
+ dialects.verified_stmt("SELECT CAST(NULL AS STRUCT<a STRUCT<b INT>> ARRAY)");
+ dialects.verified_stmt("SELECT CAST(NULL AS STRUCT<a STRUCT<b INT>> ARRAY[2])");
+ dialects.verified_stmt("SELECT CAST(NULL AS ARRAY<STRUCT<a INT>> ARRAY)");
+
+ all_dialects_where(|d| {
+ d.supports_struct_literal() && d.supports_map_literal_with_angle_brackets()
+ })
+ .verified_stmt("SELECT CAST(NULL AS MAP<INT, STRUCT<a INT>> ARRAY)");
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org