Skip to content

IMPORT INTO autodetect file format and wildcards for file path #21197

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alastori
Copy link
Collaborator

What is changed, added or deleted? (Required)

  • Format detection based on file extensions (.csv, .sql, .parquet) for IMPORT INTO jobs.
  • Wildcards are accepted in file paths, but requires one by directory level (non-recursive); added examples.
  • Add explicit note that each IMPORT INTO job must target one file format; wildcards that match mixed extensions fail the pre-check and require separate jobs.
  • Explain that compression suffixes (.gz, .zstd, .snappy, …) are ignored when TiDB infers CSV/SQL.
  • Minor wording clean-ups for consistency.

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

* Format detection based on file extensions (.csv, .sql, .parquet) for IMPORT INTO jobs.
* Wildcards are accepted in file paths, but requires one by directory level (non-recursive).
* Add explicit note that each IMPORT INTO job must target one file format; wildcards that match mixed extensions now fail the pre-check and require separate jobs.
* Explain that compression suffixes (.gz, .zstd, .snappy, …) are ignored when TiDB infers CSV/SQL/PARQUET.
* Minor wording clean-ups for consistency; no change to syntax or behavior.
Copy link

ti-chi-bot bot commented Jun 18, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tangenta for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

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 missing-translation-status This PR does not have translation status info. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 18, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @alastori, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the IMPORT INTO statement's flexibility and usability by introducing automatic file format detection based on extensions and expanding wildcard support to include directory levels in file paths. It also provides crucial clarifications regarding handling mixed file formats and compression suffixes, making the data import process more robust and user-friendly.

Highlights

  • Enhanced File Format Auto-detection: The IMPORT INTO statement now automatically determines the file format (CSV, SQL, PARQUET) based on file extensions when the FORMAT clause is omitted. This includes explicitly stating that compression suffixes (like .gz, .zstd, .snappy) are ignored during this detection process.
  • Expanded Wildcard Support in File Paths: Wildcards (* and []) can now be used not only in filenames but also to match sub-path segments (directory levels) within the fileLocation parameter. This allows for more flexible data import from structured or nested directories.
  • Clarification on Mixed File Formats with Wildcards: A new note has been added to emphasize that each IMPORT INTO job must target a single file format. If a wildcard pattern matches files with different extensions (e.g., .csv and .sql), the pre-check will fail, requiring separate import statements for each format.
  • Updated Documentation and Examples: The documentation for the fileLocation and Format sections has been revised to reflect these new capabilities and clarifications. New examples have been added, specifically demonstrating the use of wildcards in directory paths for importing data from nested structures.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@alastori
Copy link
Collaborator Author

@River2000i for technical review.

Copy link

@gemini-code-assist gemini-code-assist 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 Review

This pull request significantly enhances the IMPORT INTO documentation by adding details on automatic file format detection based on extensions and expanding wildcard usage to support directory levels. It also clarifies how compression suffixes are handled during format inference and explicitly notes the requirement for single file format per import job when using wildcards. The examples for wildcard usage, especially for nested directory structures, are a valuable addition.

My review focuses on minor wording adjustments for directness and clarity, punctuation consistency, and adherence to Markdown best practices, aligning with the provided style guide. The changes are well-structured and improve the overall quality of the documentation.

The review was guided by the Documentation Review Style Guide, particularly focusing on:

  • Clarity and Directness: Ensuring text is easy to understand and directly addresses the user (Style Guide line 22).
  • Formatting and Punctuation: Adhering to correct markdown formatting for code elements and standard English punctuation (Style Guide lines 20, 34).
  • Structure: Confirming proper use of headings and spacing around elements like lists and code blocks (Style Guide lines 32, 38).

@lilin90 lilin90 added the translation/from-docs-cn This PR is translated from a PR in pingcap/docs-cn. label Jun 18, 2025
@ti-chi-bot ti-chi-bot bot removed the missing-translation-status This PR does not have translation status info. label Jun 18, 2025
Applying suggestions from @gemini-code-assist

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@lilin90 lilin90 added the v9.0-beta.2 This PR/issue applies to TiDB v9.0-beta.2. label Jun 18, 2025
@Oreoxmt Oreoxmt self-assigned this Jun 18, 2025
@Oreoxmt Oreoxmt self-requested a review June 18, 2025 06:54
@Oreoxmt Oreoxmt added the for-release This PR relates to a TiDB release but does not have a tracked feature. label Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for-release This PR relates to a TiDB release but does not have a tracked feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. translation/from-docs-cn This PR is translated from a PR in pingcap/docs-cn. v9.0-beta.2 This PR/issue applies to TiDB v9.0-beta.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants