Skip to content

Commit cb5d3ec

Browse files
authored
parser: add SHOW RAW IMPORT JOB(S) (pingcap#67521)
ref pingcap#66461
1 parent 17ae5ca commit cb5d3ec

7 files changed

Lines changed: 11075 additions & 10994 deletions

File tree

pkg/parser/ast/dml.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3205,7 +3205,8 @@ type ShowStmt struct {
32053205

32063206
ShowGroupKey string // Used for `SHOW IMPORT GROUP <GROUP_KEY>` syntax
32073207

3208-
ImportJobID *int64 // Used for `SHOW IMPORT JOB <ID>` syntax
3208+
ImportJobID *int64 // Used for `SHOW IMPORT JOB <ID>` syntax
3209+
ImportJobRaw bool // Used for `SHOW RAW IMPORT JOB(S)` syntax
32093210

32103211
DistributionJobID *int64 // Used for `SHOW DISTRIBUTION JOB <ID>` syntax
32113212
}
@@ -3430,6 +3431,9 @@ func (n *ShowStmt) Restore(ctx *format.RestoreCtx) error {
34303431
ctx.WriteKeyWord(" PARTITION ")
34313432
ctx.WriteName(n.Partition.String())
34323433
case ShowImportJobs:
3434+
if n.ImportJobRaw {
3435+
ctx.WriteKeyWord("RAW ")
3436+
}
34333437
if n.ImportJobID != nil {
34343438
ctx.WriteKeyWord("IMPORT JOB ")
34353439
ctx.WritePlainf("%d", *n.ImportJobID)

pkg/parser/ast/dml_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,18 @@ func TestImportActions(t *testing.T) {
527527
sourceSQL: "show import job 123",
528528
expectSQL: "SHOW IMPORT JOB 123",
529529
},
530+
{
531+
sourceSQL: "show raw import jobs",
532+
expectSQL: "SHOW RAW IMPORT JOBS",
533+
},
534+
{
535+
sourceSQL: "show raw import job 123",
536+
expectSQL: "SHOW RAW IMPORT JOB 123",
537+
},
538+
{
539+
sourceSQL: "show raw import jobs where group_key = 'g'",
540+
expectSQL: "SHOW RAW IMPORT JOBS WHERE `group_key`=_UTF8MB4'g'",
541+
},
530542
{
531543
sourceSQL: "show import jobs where aa > 1",
532544
expectSQL: "SHOW IMPORT JOBS WHERE `aa`>1",

pkg/parser/keywords.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/parser/keywords_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestKeywords(t *testing.T) {
3636
}
3737

3838
func TestKeywordsLength(t *testing.T) {
39-
require.Equal(t, 678, len(parser.Keywords))
39+
require.Equal(t, 679, len(parser.Keywords))
4040

4141
reservedNr := 0
4242
for _, kw := range parser.Keywords {

pkg/parser/misc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ var tokenMap = map[string]int{
668668
"QUICK": quick,
669669
"RANGE": rangeKwd,
670670
"RATE_LIMIT": rateLimit,
671+
"RAW": raw,
671672
"READ": read,
672673
"READ_ONLY": readOnly,
673674
"REAL": realType,

0 commit comments

Comments
 (0)