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

column-mapping: set schemaID/tableID to 0 if numeric suffix is missing #236

Merged
merged 5 commits into from
May 22, 2019

Conversation

kennytm
Copy link
Contributor

@kennytm kennytm commented May 2, 2019

What problem does this PR solve?

(TOOL-1134) Support mixing names with and without numeric suffix.

What is changed and how it works?

Added an optional separator argument to column mapping. The suffix is extracted as prefix + separator + suffix.

If the name equals to prefix (without the separator), we treat this to mean using a zero numeric suffix, i.e. if prefix == "money", separator == "_":

  • money → 0
  • money_ → error
  • money_5 → 5
  • money_6 → 6
  • money_7 → 7
  • money_money_money → error
  • mon → error
  • not_money → error

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

  • Need to update the documentation

@csuzhangxc
Copy link
Member

@GregoryIan @ericsyh Have we decided to support this?

if so, money, money_ and mon are all mapped to 0, we need to underline it in the doc to avoid misuse.

@kennytm
Copy link
Contributor Author

kennytm commented May 7, 2019

We could also agree on a list of acceptable separators so that money and money_ works but not mo.

@IANTHEREAL
Copy link
Collaborator

mainly ambiguity problem, I think we can choose one in two way

  • define prefix and separator, like prefix is money and separator is _, it also means money, and money_ are mapped to 0
  • only define prefix, like prefix is money, money is mapped to 0 and ``money_` is invalid

The reason for this is based on the fact that we should provide a definition that is as simple and nature as possible, not easy to make mistakes. how about you? @kennytm @csuzhangxc

@kennytm
Copy link
Contributor Author

kennytm commented May 10, 2019

The second option seems better. I suggest the following changes:

  1. We extend the arguments to 4 elements

    arguments: [123, 'schemaprefix', 'tableprefix', '_']

    If the last argument is missing, it defaults to ''

  2. Schema name must be schemaprefix or schemaprefix + sep + schemaID

  3. Table name must be tableprefix or tableprefix + sep + tableID

@IANTHEREAL
Copy link
Collaborator

IANTHEREAL commented May 10, 2019

it's fine, and we still allow 3 elements arguments which implies sep is ""

@kennytm
Copy link
Contributor Author

kennytm commented May 10, 2019

/run-all-tests

@kennytm
Copy link
Contributor Author

kennytm commented May 10, 2019

PTAL @csuzhangxc @GregoryIan @ericsyh

@kennytm kennytm force-pushed the kennytm/fix-tool-1134 branch from 8d9773b to a7fe156 Compare May 12, 2019 09:49
@IANTHEREAL
Copy link
Collaborator

Rest LGTM

@IANTHEREAL
Copy link
Collaborator

LGTM @csuzhangxc PTAL

Copy link
Member

@csuzhangxc csuzhangxc left a comment

Choose a reason for hiding this comment

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

LGTM. Could you help to update the docs-cn or docs?

@kennytm
Copy link
Contributor Author

kennytm commented May 22, 2019

pingcap/docs#1166.

@kennytm kennytm merged commit b06622a into master May 22, 2019
@kennytm kennytm deleted the kennytm/fix-tool-1134 branch May 22, 2019 08:03
WangXiangUSTC pushed a commit to WangXiangUSTC/tidb-tools that referenced this pull request May 24, 2019
pingcap#236)

* column-mapping: set schemaID/tableID to 0 if numeric suffix is missing

* column-mapping: demand an explicit separator

* pkg/column-mapping: addressed comments

* column-mapping: addressed comments
kennytm added a commit to pingcap/docs that referenced this pull request May 30, 2019
* dev/reference/tools/dm: support new column-mapping syntax

See pingcap/tidb-tools#236

* dev/reference/tools/dm: explain the prefix in column-mapping can be empty

* dev/reference/tools/dm: further refactor the column mapping encoding docs

* Apply suggestions from code review

Co-Authored-By: Keke Yi <[email protected]>
ericsyh pushed a commit that referenced this pull request Jun 24, 2019
* diff: add connection manage (#237)

* column-mapping: set schemaID/tableID to 0 if numeric suffix is missing (#236)

* column-mapping: set schemaID/tableID to 0 if numeric suffix is missing

* column-mapping: demand an explicit separator

* pkg/column-mapping: addressed comments

* column-mapping: addressed comments

* diff: some minor fix (#242)

* remove row_id (#240)

* diff: update column's length for checkpoint table (#245)

* diff: add integration test (#239)

* diff: fix num is nil (#250)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants