Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ class AlterTableAddPartitionSuite
withNamespaceAndTable("ns", "tbl") { t =>
sql(s"CREATE TABLE $t (c int) $defaultUsing PARTITIONED BY (p int)")

withSQLConf(SQLConf.SKIP_TYPE_VALIDATION_ON_ALTER_PARTITION.key -> "true") {
withSQLConf(
SQLConf.SKIP_TYPE_VALIDATION_ON_ALTER_PARTITION.key -> "true",
SQLConf.ANSI_ENABLED.key -> "false") {
Copy link
Member Author

@HyukjinKwon HyukjinKwon Oct 31, 2022

Choose a reason for hiding this comment

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

@cloud-fan @gengliangwang @ulysses-you, this is a temporary fix to recover the test case.

The root case here seems like we don't care about spark.sql.storeAssignmentPolicy in V2:

Cast(Literal.create(raw, StringType), dt, Some(conf.sessionLocalTimeZone)).eval()

with using a plain cast (that's controlled by the ANSI flag).

Whereas seems like V1 uses the casts from PartitioningUtils.castPartitionSpec that's independent from ANSI flag (respects spark.sql.storeAssignmentPolicy). While I guess we should use the same cast, I made this fix first to make the test pass in case there's some more things to discuss about this.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to use PartitioningUtils.castPartitionSpec

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, @ulysses-you can you send a PR to fix it later?

Copy link
Contributor

Choose a reason for hiding this comment

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

sure

sql(s"ALTER TABLE $t ADD PARTITION (p='aaa')")
checkPartitions(t, Map("p" -> defaultPartitionName))
sql(s"ALTER TABLE $t DROP PARTITION (p=null)")
Expand Down