-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: Add a BulkRowWriter processor to be initially used by CTAS.
This change introduces a BulkRowWriter processor which uses the AddSSTable method to write rows from a RowSource to the target table. The processor is required to make the CTAS statement scalable. Release note: None
- Loading branch information
1 parent
0e9bd94
commit 1c87d20
Showing
7 changed files
with
427 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package sql | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/internal/client" | ||
"github.com/cockroachdb/cockroach/pkg/sql/distsqlpb" | ||
"github.com/cockroachdb/cockroach/pkg/sql/types" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// CTASPlanResultTypes is the result types for EXPORT plans. | ||
var CTASPlanResultTypes = []types.T{ | ||
*types.Bytes, // rows | ||
} | ||
|
||
// PlanAndRunCTAS plans and runs the CREATE TABLE AS command. | ||
func PlanAndRunCTAS( | ||
ctx context.Context, | ||
dsp *DistSQLPlanner, | ||
evalCtx *extendedEvalContext, | ||
txn *client.Txn, | ||
canDistribute bool, | ||
isLocal bool, | ||
in planNode, | ||
out distsqlpb.ProcessorCoreUnion, | ||
recv *DistSQLReceiver, | ||
) { | ||
planCtx := dsp.NewPlanningCtx(ctx, evalCtx, txn) | ||
planCtx.isLocal = isLocal | ||
|
||
p, err := dsp.createPlanForNode(planCtx, in) | ||
if err != nil { | ||
recv.SetError(errors.Wrapf(err, "constructing distSQL plan")) | ||
return | ||
} | ||
|
||
p.AddNoGroupingStage( | ||
out, distsqlpb.PostProcessSpec{}, CTASPlanResultTypes, distsqlpb.Ordering{}, | ||
) | ||
|
||
// The bulk row writers will emit a binary encoded BulkOpSummary. | ||
p.PlanToStreamColMap = []int{0} | ||
p.ResultTypes = CTASPlanResultTypes | ||
|
||
dsp.FinalizePlan(planCtx, &p) | ||
dsp.Run(planCtx, txn, &p, recv, evalCtx, nil /* finishedSetupFn */) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.