Skip to content

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Jul 17, 2025

What changes were proposed in this pull request?

This PR aims to add ConstraintTests.

Why are the changes needed?

To be ready for SPARK-51207 (SPIP: Constraints in DSv2) of Apache Spark 4.1.

Does this PR introduce any user-facing change?

No. This is a test suite addition.

How was this patch tested?

Pass the CIs.

Was this patch authored or co-authored using generative AI tooling?

No.

import Testing

/// A test suite for new syntaxes from SPARK-51207 (SPIP: Constraints in DSv2)
/// For now, only syntax test is here because Apache Spark 4.1 and the corresponding Apache Iceberg is not released yet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing parser can parse these syntaxes?

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review. Only 4.1.0-preveiw1 support this.

 $ swift test --filter ConstraintTests
...
􀟈  Suite ConstraintTests started.
􀟈  Test primary_key() started.
􁁛  Test primary_key() passed after 0.118 seconds.
􀟈  Test foreign_key() started.
􁁛  Test foreign_key() passed after 0.059 seconds.
􀟈  Test unique() started.
􁁛  Test unique() passed after 0.088 seconds.
􀟈  Test check() started.
􁁛  Test check() passed after 0.087 seconds.
􁁛  Suite ConstraintTests passed after 0.354 seconds.
􁁛  Test run with 4 tests passed after 0.354 seconds.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@viirya viirya Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, because you said only syntax test is here because Apache Spark 4.1 is not released yet, it makes me think that prior Apache Spark 4.1 supports only the syntax and Apache Spark 4.1 begins to support the feature fully. 🙂

@dongjoon-hyun
Copy link
Member Author

Thank you, @viirya .

For the record,

spark-sql (default)> SELECT version();
4.0.0 fa33ea000a0bda9e5a3fa1af98e8e85b8cc5e4d4
Time taken: 0.045 seconds, Fetched 1 row(s)

spark-sql (default)> CREATE TABLE primary_key(a INT, PRIMARY KEY(a));

[PARSE_SYNTAX_ERROR] Syntax error at or near '(': missing ')'. SQLSTATE: 42601 (line 1, pos 43)

== SQL ==
CREATE TABLE primary_key(a INT, PRIMARY KEY(a))
-------------------------------------------^^^

@dongjoon-hyun
Copy link
Member Author

cc @peter-toth , FYI.

@dongjoon-hyun
Copy link
Member Author

Merged to main.

@dongjoon-hyun dongjoon-hyun deleted the SPARK-52847 branch July 17, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants