Skip to content

Commit

Permalink
Merge branch 'main' into enhance-print
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 25, 2024
2 parents 82086ff + 3cc0f63 commit 26b7153
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions pkg/sql/plan/build_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func buildLoad(stmt *tree.Load, ctx CompilerContext, isPrepareStmt bool) (*Plan,
stmt.Param.Parallel = false
}
if stmt.Param.Parallel && (getCompressType(stmt.Param, fileName) != tree.NOCOMPRESS || stmt.Local) {
projectNode.ProjectList = makeCastExpr(stmt, fileName, originTableDef)
projectNode.ProjectList = makeCastExpr(stmt, fileName, originTableDef, projectNode)
}
lastNodeId = builder.appendNode(projectNode, bindCtx)
builder.qry.LoadTag = true
Expand Down Expand Up @@ -417,25 +417,22 @@ func getCompressType(param *tree.ExternParam, filepath string) string {
}
}

func makeCastExpr(stmt *tree.Load, fileName string, tableDef *TableDef) []*plan.Expr {
func makeCastExpr(stmt *tree.Load, fileName string, tableDef *TableDef, node *plan.Node) []*plan.Expr {
ret := make([]*plan.Expr, 0)
stringTyp := &plan.Type{
Id: int32(types.T_varchar),
}
for i := 0; i < len(tableDef.Cols); i++ {
typ := tableDef.Cols[i].Typ
expr := &plan.Expr{
Typ: *stringTyp,
Expr: &plan.Expr_Col{
Col: &plan.ColRef{
RelPos: 0,
ColPos: int32(i),
},
},
typ := node.ProjectList[i].Typ
expr := node.ProjectList[i].Expr
planExpr := &plan.Expr{
Typ: *stringTyp,
Expr: expr,
}

expr, _ = makePlan2CastExpr(stmt.Param.Ctx, expr, typ)
ret = append(ret, expr)
planExpr, _ = makePlan2CastExpr(stmt.Param.Ctx, planExpr, typ)
ret = append(ret, planExpr)
}

return ret
}

0 comments on commit 26b7153

Please sign in to comment.