Skip to content

importccl: fix panic when importing CSV with virtual columns#66730

Merged
craig[bot] merged 1 commit into
cockroachdb:masterfrom
mgartner:66694-import-virtual-column-panic
Jun 23, 2021
Merged

importccl: fix panic when importing CSV with virtual columns#66730
craig[bot] merged 1 commit into
cockroachdb:masterfrom
mgartner:66694-import-virtual-column-panic

Conversation

@mgartner

Copy link
Copy Markdown
Contributor

Previously, IMPORT TABLE would panic for a CSV import when the table
included a virtual computed column. This was caused by empty
SessionData being passed to sql.NewTableDesc in
importccl.MakeSimpleTableDescriptor which consults session data to
determine if all nodes in the cluster are running a version that
supports virtual computed columns.

This commit fixes the issue by returning an error in
importccl.MakeSimpleTableDescriptor before calling sql.NewTableDesc
if the IMPORT TABLE statement specifies a virtual computed
column. This is acceptable behavior because stored computed columns are
also not supported in the IMPORT TABLE statement.

Fixes #66694

Release note (bug fix): A bug has been fixed which caused internal
errors when running an IMPORT TABLE statement with a virtual computed
column to import a CSV file. This bug has been present since virtual
computed columns were introduced in version 21.1.0.

@mgartner mgartner requested review from a team, RaduBerinde and adityamaru and removed request for a team June 22, 2021 17:37
@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@adityamaru adityamaru left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Heh timely - #66732. Thanks for doing this!

Previously, `IMPORT TABLE` would panic for a CSV import when the table
included a virtual computed column. This was caused by empty
`SessionData` being passed to `sql.NewTableDesc` in
`importccl.MakeSimpleTableDescriptor` which consults session data to
determine if all nodes in the cluster are running a version that
supports virtual computed columns.

This commit fixes the issue by returning an error in
`importccl.MakeSimpleTableDescriptor` before calling `sql.NewTableDesc`
if the `IMPORT TABLE` statement specifies a virtual computed
column. This is acceptable behavior because stored computed columns are
also not supported in the `IMPORT TABLE` statement.

Fixes cockroachdb#66694

Release note (bug fix): A bug has been fixed which caused internal
errors when running an `IMPORT TABLE` statement with a virtual computed
column to import a CSV file. This bug has been present since virtual
computed columns were introduced in version 21.1.0.
@mgartner mgartner force-pushed the 66694-import-virtual-column-panic branch from 5876a12 to 9f7af87 Compare June 22, 2021 21:22
@mgartner

Copy link
Copy Markdown
Contributor Author

@adityamaru made some minor changes, PTAL.

@mgartner

Copy link
Copy Markdown
Contributor Author

TFTR!

bors r+

@craig

craig Bot commented Jun 23, 2021

Copy link
Copy Markdown
Contributor

Build succeeded:

@craig craig Bot merged commit ebc0046 into cockroachdb:master Jun 23, 2021
@mgartner mgartner deleted the 66694-import-virtual-column-panic branch June 23, 2021 03:14
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.

panic when importing into a table with virtual computed columns

3 participants