Skip to content

parser: add SHOW RAW IMPORT JOB(S)#67521

Merged
ti-chi-bot[bot] merged 4 commits into
pingcap:masterfrom
GMHDBJD:pr-66502-parser
Apr 13, 2026
Merged

parser: add SHOW RAW IMPORT JOB(S)#67521
ti-chi-bot[bot] merged 4 commits into
pingcap:masterfrom
GMHDBJD:pr-66502-parser

Conversation

@GMHDBJD
Copy link
Copy Markdown
Collaborator

@GMHDBJD GMHDBJD commented Apr 2, 2026

What problem does this PR solve?

Issue Number: ref #66461

Problem Summary:

This PR extracts the parser-related part from #66502 so the syntax and AST changes for SHOW RAW IMPORT JOB(S) can be reviewed separately.

What changed and how does it work?

  • Add parser support for SHOW RAW IMPORT JOB <job_id> and SHOW RAW IMPORT JOBS.
  • Add ImportJobRaw to ast.ShowStmt and restore the RAW prefix in SQL text.
  • Add parser coverage for the new syntax and update keyword metadata/tests for RAW.
  • Regenerate parser artifacts on top of current master.
  • Follow-up PRs will wire planner, executor, and import SDK behavior.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Added parser support for `SHOW RAW IMPORT JOB(S)`.

Summary by CodeRabbit

  • New Features

    • Added support for SHOW RAW IMPORT JOB(S) (e.g., SHOW RAW IMPORT JOBS, SHOW RAW IMPORT JOB ) to produce raw-format import job output.
    • Parser now recognizes RAW as a keyword so RAW can be used in import-job queries.
  • Tests

    • Extended test coverage for SHOW RAW IMPORT JOBS variants: listing, single-job lookup, and filtered queries.

(cherry picked from commit 3b7155d)
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 2, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1beaadab-690a-47f5-8a18-b49317891a81

📥 Commits

Reviewing files that changed from the base of the PR and between c4c9867 and 0fe990c.

📒 Files selected for processing (5)
  • pkg/parser/keywords.go
  • pkg/parser/keywords_test.go
  • pkg/parser/misc.go
  • pkg/parser/parser.go
  • pkg/parser/parser.y
✅ Files skipped from review due to trivial changes (2)
  • pkg/parser/misc.go
  • pkg/parser/keywords.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/parser/keywords_test.go
  • pkg/parser/parser.y

📝 Walkthrough

Walkthrough

Adds support for the RAW prefix for import-job SHOW statements: parser grammar recognizes RAW, lexer/token map registers it, AST ShowStmt gains ImportJobRaw bool, restore output conditionally emits RAW, and tests updated to cover SHOW RAW IMPORT JOB(S) forms.

Changes

Cohort / File(s) Summary
AST & Tests
pkg/parser/ast/dml.go, pkg/parser/ast/dml_test.go
Added ImportJobRaw bool to ShowStmt; ShowStmt.Restore conditionally emits RAW when set. Added test cases for SHOW RAW IMPORT JOBS, SHOW RAW IMPORT JOB 123, and a filtered WHERE variant.
Keyword Registration & Token Map
pkg/parser/keywords.go, pkg/parser/misc.go, pkg/parser/keywords_test.go
Registered RAW as a non-reserved TiDB keyword; added "RAW" -> raw to tokenMap; updated keyword-count assertion in tests (now expects 679 entries).
Parser Grammar
pkg/parser/parser.y
Extended SHOW parsing to accept optional RAW via new nonterminals (ShowImportJobTarget, ShowImportJobsTarget) and set ImportJobRaw on constructed ShowStmt; minor adjacent formatting/alignment edits in grammar actions.

Sequence Diagram(s)

sequenceDiagram
    participant Client as SQL Input
    participant Lexer
    participant Parser
    participant AST as AST Builder

    Client->>Lexer: "SHOW RAW IMPORT JOBS"
    Lexer->>Parser: tokens: SHOW, RAW, IMPORT, JOBS
    Parser->>Parser: match ShowImportJobsTarget (detect RAW)
    Parser->>AST: construct ShowStmt{Tp: ShowImportJobs, ImportJobRaw: true}
    AST-->>Client: ShowStmt(ImportJobRaw=true)

    Client->>Lexer: "SHOW RAW IMPORT JOB 123 WHERE group_key='g'"
    Lexer->>Parser: tokens: SHOW, RAW, IMPORT, JOB, 123, WHERE, IDENT, '=', STRING
    Parser->>Parser: match ShowImportJobTarget + Int64Num + filter
    Parser->>AST: construct ShowStmt{Tp: ShowImportJobs, ImportJobID: 123, ImportJobRaw: true, Filter: ...}
    AST-->>Client: ShowStmt(ImportJobID=123, ImportJobRaw=true, Filter=...)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • breezewish
  • hawkingrei
  • bb7133
  • yudongusa
  • lance6716

Poem

🐰 I nibbled tokens in the glade,
Found RAW hiding in the shade,
My whiskers twitched, the parser sang,
AST hops light — the test bells rang,
Little rabbit stamps the new parade.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding parser support for SHOW RAW IMPORT JOB(S) syntax.
Description check ✅ Passed The description includes the required issue reference, clear problem statement, detailed explanation of changes, and appropriate checklist items marked; it follows the repository template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Command failed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 2, 2026
@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 2, 2026

Hi @GMHDBJD. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD GMHDBJD marked this pull request as ready for review April 2, 2026 10:48
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 2, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented Apr 2, 2026

Review Complete

Findings: 0 issues
Posted: 0
Duplicates/Skipped: 0

ℹ️ Learn more details on Pantheon AI.

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot left a comment

Choose a reason for hiding this comment

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

✅ Code looks good. No issues found.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/parser/ast/dml.go (1)

3434-3443: ⚠️ Potential issue | 🟠 Major

Propagate restoreShowLikeOrWhereOpt() errors in the SHOW ... IMPORT JOBS restore path.

At Line 3442, the returned error is ignored. This can silently mask restore failures for both RAW and non-RAW SHOW IMPORT JOBS.

Suggested fix
 		} else {
 			ctx.WriteKeyWord("IMPORT JOBS")
-			restoreShowLikeOrWhereOpt()
+			if err := restoreShowLikeOrWhereOpt(); err != nil {
+				return err
+			}
 		}

As per coding guidelines, keep error handling actionable and contextual; avoid silently swallowing errors.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/parser/ast/dml.go` around lines 3434 - 3443, The SHOW IMPORT JOBS restore
path currently calls restoreShowLikeOrWhereOpt() and ignores its error; update
the call site so you capture the returned error from
restoreShowLikeOrWhereOpt(), and if non-nil return (or wrap with contextual
message) up the call stack instead of discarding it; ensure the surrounding
function (the restore/format method that contains the ctx.WriteKeyWord("IMPORT
JOBS") logic) propagates the error to the caller so restore failures for RAW and
non-RAW paths aren't silently swallowed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/parser/ast/dml.go`:
- Around line 3434-3443: The SHOW IMPORT JOBS restore path currently calls
restoreShowLikeOrWhereOpt() and ignores its error; update the call site so you
capture the returned error from restoreShowLikeOrWhereOpt(), and if non-nil
return (or wrap with contextual message) up the call stack instead of discarding
it; ensure the surrounding function (the restore/format method that contains the
ctx.WriteKeyWord("IMPORT JOBS") logic) propagates the error to the caller so
restore failures for RAW and non-RAW paths aren't silently swallowed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 26dad9b9-101e-4c0c-b29c-8353c70e3505

📥 Commits

Reviewing files that changed from the base of the PR and between 4d20c4a and e1d0743.

📒 Files selected for processing (7)
  • pkg/parser/ast/dml.go
  • pkg/parser/ast/dml_test.go
  • pkg/parser/keywords.go
  • pkg/parser/keywords_test.go
  • pkg/parser/misc.go
  • pkg/parser/parser.go
  • pkg/parser/parser.y

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.4415%. Comparing base (a83fcdb) to head (0fe990c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67521        +/-   ##
================================================
- Coverage   77.6233%   77.4415%   -0.1819%     
================================================
  Files          1981       1965        -16     
  Lines        548326     548694       +368     
================================================
- Hits         425629     424917       -712     
- Misses       121887     123775      +1888     
+ Partials        810          2       -808     
Flag Coverage Δ
integration 41.0983% <ø> (+6.7586%) ⬆️
unit 76.6516% <100.0000%> (+0.2823%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 61.5065% <ø> (ø)
parser ∅ <ø> (∅)
br 49.9052% <ø> (-10.5644%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ingress-bot
Copy link
Copy Markdown

🔍 Starting code review for this PR...

Copy link
Copy Markdown

@ingress-bot ingress-bot left a comment

Choose a reason for hiding this comment

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

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 1
  • Inline comments: 1
  • Summary-only findings (no inline anchor): 0
Findings (highest risk first)

⚠️ [Major] (1)

  1. ImportJobRaw flag silently dropped at plan-build time — SHOW RAW behaves as SHOW (pkg/parser/ast/dml.go:3209, pkg/planner/core/planbuilder.go:3498, pkg/executor/builder.go:930, pkg/planner/core/operator/logicalop/logical_show.go:61)

Comment thread pkg/parser/ast/dml.go
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 3, 2026
@ingress-bot
Copy link
Copy Markdown

🔍 Processing follow-up on review comments...

Copy link
Copy Markdown
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

rest lgtm

Comment thread pkg/parser/parser.y Outdated
ImportJobID: &v,
}
}
| "SHOW" "RAW" "IMPORT" "JOB" Int64Num
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.

can we merge the rule with above, so we can decode RAW as optional

below "RAW" "IMPORT" "JOBS" too

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Refactored this into helper nonterminals in parser.y so both SHOW RAW IMPORT JOB <id> and SHOW RAW IMPORT JOBS reuse the same optional-RAW structure without introducing parser conflicts. Updated in 0aac5bb.

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 3, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 3, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-03 08:13:05.851522181 +0000 UTC m=+511991.056882228: ☑️ agreed by lance6716.
  • 2026-04-03 09:27:49.658422346 +0000 UTC m=+516474.863782403: ☑️ agreed by D3Hunter.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 3, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 3, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 3, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 3, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 8, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, lance6716, yudongusa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the approved label Apr 8, 2026
@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 10, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 10, 2026

@GMHDBJD: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 10, 2026

/retest

@hawkingrei
Copy link
Copy Markdown
Member

/ok-to-test

@ti-chi-bot ti-chi-bot Bot added the ok-to-test Indicates a PR is ready to be tested. label Apr 10, 2026
@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 10, 2026

/retest

2 similar comments
@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 10, 2026

/retest

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 11, 2026

/retest

@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 13, 2026

/retest

1 similar comment
@GMHDBJD
Copy link
Copy Markdown
Collaborator Author

GMHDBJD commented Apr 13, 2026

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 885b297 into pingcap:master Apr 13, 2026
35 checks passed
@GMHDBJD GMHDBJD deleted the pr-66502-parser branch April 13, 2026 12:23
premal pushed a commit to premal/tidb that referenced this pull request Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants