Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-48759][SQL] Add migration doc for CREATE TABLE AS SELECT behavior change behavior change since Spark 3.4 #47152

Closed
wants to merge 2 commits into from

Conversation

asl3
Copy link
Contributor

@asl3 asl3 commented Jun 30, 2024

What changes were proposed in this pull request?

Add migration guide for CREATE TABLE AS SELECT... behavior change.

SPARK-41859 changes the behaviour for CREATE TABLE AS SELECT ... from OVERWRITE to APPEND when spark.sql.legacy.allowNonEmptyLocationInCTAS is set to true:

drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 1 as col union all select 2 as col;
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 3 as col union all select 4 as col;
select * from test_table;

This produces {3, 4} in Spark <3.4.0 and {1, 2, 3, 4} in Spark 3.4.0 and later. This is a silent change in spark.sql.legacy.allowNonEmptyLocationInCTAS behaviour which introduces wrong results in the user application.

Why are the changes needed?

This documents a behavior change starting in Spark 3.4 for CREATE TABLE AS SELECT

Does this PR introduce any user-facing change?

No

How was this patch tested?

doc build

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

No.

@github-actions github-actions bot added the DOCS label Jun 30, 2024
@asl3
Copy link
Contributor Author

asl3 commented Jun 30, 2024

cc @cloud-fan

@@ -97,6 +97,7 @@ license: |
- Since Spark 3.4, `BinaryType` is not supported in CSV datasource. In Spark 3.3 or earlier, users can write binary columns in CSV datasource, but the output content in CSV files is `Object.toString()` which is meaningless; meanwhile, if users read CSV tables with binary columns, Spark will throw an `Unsupported type: binary` exception.
- Since Spark 3.4, bloom filter joins are enabled by default. To restore the legacy behavior, set `spark.sql.optimizer.runtime.bloomFilter.enabled` to `false`.
- Since Spark 3.4, when schema inference on external Parquet files, INT64 timestamps with annotation `isAdjustedToUTC=false` will be inferred as TimestampNTZ type instead of Timestamp type. To restore the legacy behavior, set `spark.sql.parquet.inferTimestampNTZ.enabled` to `false`.
- Since Spark 3.4, the behaviour for `CREATE TABLE AS SELECT ...` is changed from OVERWRITE to APPEND when `spark.sql.legacy.allowNonEmptyLocationInCTAS` is set to `true`. To restore the legacy behavior, set `spark.sql.legacy.allowNonEmptyLocationInCTAS` to `false`.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no way to restore the old behavior... I think we should ask users to move away from the legacy behavior that allows non-empty table location for CTAS.

@asl3 asl3 requested a review from cloud-fan July 1, 2024 15:09
@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 8a5f4e0 Jul 2, 2024
@cloud-fan
Copy link
Contributor

@asl3 can you help to create a PR against branch 3.5?

cloud-fan pushed a commit that referenced this pull request Jul 2, 2024
…ior change behavior change since Spark 3.4 (branch-3.5)

### What changes were proposed in this pull request?

This PR is a follow-up to #47152 against `branch-3.5`.

Add migration guide for `CREATE TABLE AS SELECT...` behavior change.

SPARK-41859 changes the behaviour for `CREATE TABLE AS SELECT ...` from OVERWRITE to APPEND when `spark.sql.legacy.allowNonEmptyLocationInCTAS` is set to `true`:

```
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 1 as col union all select 2 as col;
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 3 as col union all select 4 as col;
select * from test_table;

```
This produces {3, 4} in Spark <3.4.0 and {1, 2, 3, 4} in Spark 3.4.0 and later. This is a silent change in `spark.sql.legacy.allowNonEmptyLocationInCTAS` behaviour which introduces wrong results in the user application.

### Why are the changes needed?
This documents a behavior change starting in Spark 3.4 for `CREATE TABLE AS SELECT`

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
`doc build
`
### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #47178 from asl3/allowNonEmptyLocationInCTAS-3.5.

Authored-by: Amanda Liu <amanda.liu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan pushed a commit that referenced this pull request Jul 2, 2024
…ior change behavior change since Spark 3.4 (branch-3.5)

### What changes were proposed in this pull request?

This PR is a follow-up to #47152 against `branch-3.5`.

Add migration guide for `CREATE TABLE AS SELECT...` behavior change.

SPARK-41859 changes the behaviour for `CREATE TABLE AS SELECT ...` from OVERWRITE to APPEND when `spark.sql.legacy.allowNonEmptyLocationInCTAS` is set to `true`:

```
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 1 as col union all select 2 as col;
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 3 as col union all select 4 as col;
select * from test_table;

```
This produces {3, 4} in Spark <3.4.0 and {1, 2, 3, 4} in Spark 3.4.0 and later. This is a silent change in `spark.sql.legacy.allowNonEmptyLocationInCTAS` behaviour which introduces wrong results in the user application.

### Why are the changes needed?
This documents a behavior change starting in Spark 3.4 for `CREATE TABLE AS SELECT`

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
`doc build
`
### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #47178 from asl3/allowNonEmptyLocationInCTAS-3.5.

Authored-by: Amanda Liu <amanda.liu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit ef4e456)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
gaecoli pushed a commit to gaecoli/spark that referenced this pull request Jul 10, 2024
…ior change behavior change since Spark 3.4 (branch-3.5)

### What changes were proposed in this pull request?

This PR is a follow-up to apache#47152 against `branch-3.5`.

Add migration guide for `CREATE TABLE AS SELECT...` behavior change.

SPARK-41859 changes the behaviour for `CREATE TABLE AS SELECT ...` from OVERWRITE to APPEND when `spark.sql.legacy.allowNonEmptyLocationInCTAS` is set to `true`:

```
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 1 as col union all select 2 as col;
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 3 as col union all select 4 as col;
select * from test_table;

```
This produces {3, 4} in Spark <3.4.0 and {1, 2, 3, 4} in Spark 3.4.0 and later. This is a silent change in `spark.sql.legacy.allowNonEmptyLocationInCTAS` behaviour which introduces wrong results in the user application.

### Why are the changes needed?
This documents a behavior change starting in Spark 3.4 for `CREATE TABLE AS SELECT`

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
`doc build
`
### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#47178 from asl3/allowNonEmptyLocationInCTAS-3.5.

Authored-by: Amanda Liu <amanda.liu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
szehon-ho pushed a commit to szehon-ho/spark that referenced this pull request Aug 7, 2024
…ior change behavior change since Spark 3.4 (branch-3.5)

### What changes were proposed in this pull request?

This PR is a follow-up to apache#47152 against `branch-3.5`.

Add migration guide for `CREATE TABLE AS SELECT...` behavior change.

SPARK-41859 changes the behaviour for `CREATE TABLE AS SELECT ...` from OVERWRITE to APPEND when `spark.sql.legacy.allowNonEmptyLocationInCTAS` is set to `true`:

```
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 1 as col union all select 2 as col;
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 3 as col union all select 4 as col;
select * from test_table;

```
This produces {3, 4} in Spark <3.4.0 and {1, 2, 3, 4} in Spark 3.4.0 and later. This is a silent change in `spark.sql.legacy.allowNonEmptyLocationInCTAS` behaviour which introduces wrong results in the user application.

### Why are the changes needed?
This documents a behavior change starting in Spark 3.4 for `CREATE TABLE AS SELECT`

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
`doc build
`
### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#47178 from asl3/allowNonEmptyLocationInCTAS-3.5.

Authored-by: Amanda Liu <amanda.liu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit ef4e456)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
attilapiros pushed a commit to attilapiros/spark that referenced this pull request Oct 4, 2024
…ior change behavior change since Spark 3.4

### What changes were proposed in this pull request?

Add migration guide for `CREATE TABLE AS SELECT...` behavior change.

SPARK-41859 changes the behaviour for `CREATE TABLE AS SELECT ...` from OVERWRITE to APPEND when `spark.sql.legacy.allowNonEmptyLocationInCTAS` is set to `true`:

```
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 1 as col union all select 2 as col;
drop table if exists test_table;
create table test_table location '/tmp/test_table' stored as parquet as select 3 as col union all select 4 as col;
select * from test_table;

```
This produces {3, 4} in Spark <3.4.0 and {1, 2, 3, 4} in Spark 3.4.0 and later. This is a silent change in `spark.sql.legacy.allowNonEmptyLocationInCTAS` behaviour which introduces wrong results in the user application.

### Why are the changes needed?
This documents a behavior change starting in Spark 3.4 for `CREATE TABLE AS SELECT`

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
`doc build
`
### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#47152 from asl3/allowNonEmptyLocationInCTAS.

Authored-by: Amanda Liu <amanda.liu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants