Skip to content
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

Debug TiDB Cloud Documentation: Import Local Files to TiDB Cloud #15739

Closed
Tracked by #15480
qiancai opened this issue Dec 16, 2023 · 4 comments · Fixed by #16135
Closed
Tracked by #15480

Debug TiDB Cloud Documentation: Import Local Files to TiDB Cloud #15739

qiancai opened this issue Dec 16, 2023 · 4 comments · Fixed by #16135
Assignees
Labels
2024-tidb-docs-dash This issue or PR is included in the 2024 TiDB Docs Dash event.

Comments

@qiancai
Copy link
Collaborator

qiancai commented Dec 16, 2023

This issue is a sub-issue of Debug TiDB Cloud Documentation: Summary Issue · Issue #15480 · pingcap/docs. The purpose of this sub-issue is to verify and debug the Import Local Files to TiDB Cloud document.

You can follow the instructions provided in #15480 to verify and debug the instructions in this document.

  1. After finishing your verification, please add your verification result to this sub-issue as a comment. The result can be the issues you encounter, the mistakes you find, or any other findings. If everything looks fine, you can also add it as a comment.
  2. For any issues you found during the verification, welcome to create a pull request (PR) to fix them directly. In the pull request, please indicate which issue this PR resolves in the PR description (for example, fix #15739). To learn how to create a pull request, see TiDB Documentation Contributing Guide.

Note: Currently, the TiDB Cloud documentation is in English only and it is stored in the release-7.5 branch of pingcap/docs for reusing the SQL documentation of TiDB. Hence, to create a pull request for TiDB Cloud documentation, make sure that your PR is based on the release-7.5 branch.

Your contribution to testing and verifying the documentation is highly appreciated!

@qiancai qiancai added the 2024-tidb-docs-dash This issue or PR is included in the 2024 TiDB Docs Dash event. label Dec 16, 2023
@RakerZh
Copy link
Contributor

RakerZh commented Jan 1, 2024

/assign

@rpaik
Copy link
Member

rpaik commented Jan 10, 2024

👋 @RakerZh, just a quick reminder to make your TiDB Docs Dash contributions by January 12 at 07:59 UTC.

Let us know if you have any questions!

@RakerZh
Copy link
Contributor

RakerZh commented Jan 12, 2024

Test Result

Good. Almost all passed.

Suggestion

Hope there would be more options to import a csv file. For example, when a user imports file, there is only primary key option to click. It will be great if there were key selection from PRI MUI UNI NONE and NULL option.

Issue

A small issue for split files larger than 50MB, when total number of lines in file is not exactly divisible by $n.
Shell script in document:

#!/bin/bash
n=$1
file_path=$2
file_extension="${file_path##*.}"
file_name="${file_path%.*}"
lines_per_file=$(( $(wc -l < $file_path) / $n ))
split -d -a 1 -l $lines_per_file $file_path $file_name.
for (( i=0; i<$n; i++ ))
do
    mv $file_name.$i $file_name.$i.$file_extension
done
sh ./split.sh 4 3.csv

Result: ls -l

.rw-r--r--  467M  12 Jan 00:49  3.0.csv
.rw-r--r--  469M  12 Jan 00:49  3.1.csv
.rw-r--r--  468M  12 Jan 00:49  3.2.csv
.rw-r--r--  469M  12 Jan 00:49  3.3.csv
.rw-r--r--   879  12 Jan 00:49  3.4
.rw-r--r--@ 1.9G   1 Jan 22:12  3.csv
.rw-r--r--   281  12 Jan 00:44  split.sh

There will be a 3.4 file with extra lines but without .csv.

Fixed:

#!/bin/bash
n=$1
file_path=$2
file_extension="${file_path##*.}"
file_name="${file_path%.*}"
total_lines=$(wc -l < $file_path)
lines_per_file=$(( (total_lines + n - 1) / n )) 
split -d -a 1 -l $lines_per_file $file_path $file_name.
for (( i=0; i<$n; i++ ))
do
    mv $file_name.$i $file_name.$i.$file_extension
done

This will round up the division.
Result after running the same code above: ls -l

.rw-r--r--  467M  12 Jan 00:56  3.0.csv
.rw-r--r--  469M  12 Jan 00:56  3.1.csv
.rw-r--r--  468M  12 Jan 00:56  3.2.csv
.rw-r--r--  469M  12 Jan 00:56  3.3.csv
.rw-r--r--@ 1.9G   1 Jan 22:12  3.csv

@hfxsd
Copy link
Collaborator

hfxsd commented Jan 12, 2024

Hi @RakerZh, Thank you sincerely for your valuable contribution to our Docs Dash compaign. Your dedicated effort has significantly enhanced the quality of TiDB documentation. We deeply appreciate your hard work and commitment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2024-tidb-docs-dash This issue or PR is included in the 2024 TiDB Docs Dash event.
Development

Successfully merging a pull request may close this issue.

4 participants