Skip to content

Conversation

@Hisoka-X
Copy link
Member

@Hisoka-X Hisoka-X commented Jul 29, 2023

What changes were proposed in this pull request?

Fix INSERT BY NAME returns nonsensical error message on v1 datasource.
eg:

CREATE TABLE bug(c1 INT);

INSERT INTO bug BY NAME SELECT 1 AS c2;

==> Multi-part identifier cannot be empty.

After PR:

[INCOMPATIBLE_DATA_FOR_TABLE.CANNOT_FIND_DATA] Cannot write incompatible data for the table `spark_catalog`.`default`.`bug`: Cannot find data for the output column `c1`.

Also fixed the same issue when throwing other INCOMPATIBLE_DATA_FOR_TABLE type errors

Why are the changes needed?

Fix the error msg nonsensical.

Does this PR introduce any user-facing change?

Yes, the error msg in v1 insert by name will be changed.

How was this patch tested?

add new test.

@github-actions github-actions bot added the SQL label Jul 29, 2023
@Hisoka-X
Copy link
Member Author

cc @cloud-fan

@cloud-fan
Copy link
Contributor

can we update the PR description for the new changes?

@Hisoka-X
Copy link
Member Author

can we update the PR description for the new changes?

Done

@cloud-fan
Copy link
Contributor

[INSERT_COLUMN_ARITY_MISMATCH.NOT_ENOUGH_DATA_COLUMNS] Cannot write to `spark_catalog`.`default`.`bug`, the reason is not enough data columns:
Table columns: `c1`.
Data columns: `c2`.

For by-name insert, shall we just say "incompatible data columns"? The number of columns does match here.

@Hisoka-X
Copy link
Member Author

Hisoka-X commented Aug 1, 2023

[INSERT_COLUMN_ARITY_MISMATCH.NOT_ENOUGH_DATA_COLUMNS] Cannot write to `spark_catalog`.`default`.`bug`, the reason is not enough data columns:
Table columns: `c1`.
Data columns: `c2`.

For by-name insert, shall we just say "incompatible data columns"? The number of columns does match here.

Oh, let me align v1 and v2 errors.

@cloud-fan
Copy link
Contributor

@MaxGekk does this PR align with your plan of unifying the assignment errors?

@MaxGekk
Copy link
Member

MaxGekk commented Aug 8, 2023

@cloud-fan In my PR #42393, I am going to touch non-BY NAME functionality so far.

@Hisoka-X
Copy link
Member Author

Hi @cloud-fan @MaxGekk Shall we continue push on this PR? Thanks.

@github-actions github-actions bot added the DOCS label Aug 18, 2023
@Hisoka-X Hisoka-X requested a review from cloud-fan August 31, 2023 06:08
},
"EXTRA_FIELDS" : {
"message" : [
"Cannot write extra fields <colName>."
Copy link
Contributor

Choose a reason for hiding this comment

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

it's one column or multiple columns?

Copy link
Member Author

Choose a reason for hiding this comment

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

multiple columns, so I do some change, please check it again. Thanks.

@cloud-fan
Copy link
Contributor

thanks, merging to master/3.5!

@cloud-fan cloud-fan closed this in 00f6699 Sep 1, 2023
cloud-fan pushed a commit that referenced this pull request Sep 1, 2023
### What changes were proposed in this pull request?
Fix INSERT BY NAME returns nonsensical error message on v1 datasource.
eg:
```scala
CREATE TABLE bug(c1 INT);

INSERT INTO bug BY NAME SELECT 1 AS c2;

==> Multi-part identifier cannot be empty.
```
After PR:
```scala
[INCOMPATIBLE_DATA_FOR_TABLE.CANNOT_FIND_DATA] Cannot write incompatible data for the table `spark_catalog`.`default`.`bug`: Cannot find data for the output column `c1`.
```

Also fixed the same issue when throwing other INCOMPATIBLE_DATA_FOR_TABLE type errors

### Why are the changes needed?
Fix the error msg nonsensical.

### Does this PR introduce _any_ user-facing change?
Yes, the error msg in v1 insert by name will be changed.

### How was this patch tested?
add new test.

Closes #42220 from Hisoka-X/SPARK-44577_insert_by_name_bug_fix.

Authored-by: Jia Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 00f6699)
Signed-off-by: Wenchen Fan <[email protected]>
@Hisoka-X
Copy link
Member Author

Hisoka-X commented Sep 1, 2023

Thanks @cloud-fan and @MaxGekk

@Hisoka-X Hisoka-X deleted the SPARK-44577_insert_by_name_bug_fix branch September 1, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants