Skip to content

Spark dialect rejects empty struct() expressions #3048

Backlog

Description

@Ritesh17rb

With sqlparser 0.63.0 and SparkSqlDialect, SELECT struct(); fails with Expected: an expression, found: ) at Line: 1, Column: 15. Spark 4.2.0 accepts this syntax and returns an empty struct ({}).

Reproduction:

use sqlparser::{dialect::SparkSqlDialect, parser::Parser};
let result = Parser::parse_sql(&SparkSqlDialect {}, "SELECT struct();");
assert!(result.is_ok(), "{result:?}");

parse_struct_literal in src/parser/mod.rs unconditionally calls parse_comma_separated after consuming (, so an immediate ) cannot produce Expr::Struct { values: vec![], fields: vec![] }. I checked the same code on current main as well.

Could the Spark dialect accept an empty struct argument list? This is a syntax request; support for evaluating the resulting empty struct is separate.

Found while addressing the deferred Spark compatibility case in apache/datafusion-spark#410 (original issue apache/datafusion-spark#364).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions