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

importccl: add support for SQLFns in pgdump #50850

Merged
merged 2 commits into from
Jul 3, 2020
Merged

importccl: add support for SQLFns in pgdump #50850

merged 2 commits into from
Jul 3, 2020

Conversation

maddyblue
Copy link
Contributor

SQLFns are functions users can call from SQL that create and execute
SQL. AddGeometryColumn, for example, creates an ADD COLUMN statement and
executes it. Add support for these in IMPORT PGDUMP by detecting them,
running them, and feeding them back in to the table statement reader.

Release note (sql change): add support for AddGeometryColumn and other
functions that mutate schema in IMPORT PGDUMP.

@maddyblue maddyblue requested review from dt, otan and a team June 30, 2020 22:49
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@maddyblue
Copy link
Contributor Author

RFAL @pbardea @Anzoteh96

Copy link
Member

@dt dt left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Anzoteh96, @dt, @mjibson, @otan, and @pbardea)


pkg/ccl/importccl/read_import_pgdump.go, line 400 at r2 (raw file):

	case *tree.Select:
		switch sel := stmt.Select.(type) {
		case *tree.SelectClause:

should this have a default counterpart for unsupported?


pkg/ccl/importccl/read_import_pgdump.go, line 403 at r2 (raw file):

			for _, selExpr := range sel.Exprs {
				switch expr := selExpr.Expr.(type) {
				case *tree.FuncExpr:

ditto, what if it is something else?


pkg/ccl/importccl/read_import_pgdump.go, line 414 at r2 (raw file):

					fn := ov.SQLFn
					if fn == nil {
						continue

huh, in what cases do we get here / why are they okay to ignore?

Copy link
Contributor Author

@maddyblue maddyblue left a comment

Choose a reason for hiding this comment

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

I've added some comments regarding what to do about non schema-transforming SELECTs, and how we just ignore them. This was previously the implicit policy, and I'm making it more explicit with these comments. Since (AFAIK) no users have complained about IMPORT PGDUMP not executing their SELECTs (except in this geospatial case), I think it's ok to ignore them. Thoughts?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Anzoteh96, @dt, @otan, and @pbardea)


pkg/ccl/importccl/read_import_pgdump.go, line 400 at r2 (raw file):

Previously, dt (David Taylor) wrote…

should this have a default counterpart for unsupported?

I don't know? We were already ignoring any SELECTs, so I don't see why we would disallow them in this commit.


pkg/ccl/importccl/read_import_pgdump.go, line 403 at r2 (raw file):

Previously, dt (David Taylor) wrote…

ditto, what if it is something else?

Same as above: we already were ignoring these. If it is decided to care about erroring on SELECTs on other unsupported things, those should be added and tested in another PR.


pkg/ccl/importccl/read_import_pgdump.go, line 414 at r2 (raw file):

Previously, dt (David Taylor) wrote…

huh, in what cases do we get here / why are they okay to ignore?

A non-sqlfn is ignored just like they were before this pr.

semaCtx := tree.MakeSemaContext()
_, err := expr.TypeCheck(ctx, &semaCtx, nil /* desired */)
if err != nil {
return err
Copy link

@Anzoteh96 Anzoteh96 Jul 2, 2020

Choose a reason for hiding this comment

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

Personal preference (take with a grain of salt :) ), I would condense this to

if _, err := expr.TypeCheck(ctx, &semaCtx, nil); err != nil {
return err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@maddyblue
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 3, 2020

Build failed

SQLFns are functions users can call from SQL that create and execute
SQL. AddGeometryColumn, for example, creates an ADD COLUMN statement and
executes it. Add support for these in IMPORT PGDUMP by detecting them,
running them, and feeding them back in to the table statement reader.

Release note (sql change): add support for AddGeometryColumn and other
functions that mutate schema in IMPORT PGDUMP.
@maddyblue
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 3, 2020

Build succeeded

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.

4 participants