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

Fix float value in create statement #198

Merged
merged 1 commit into from
Aug 26, 2019

Conversation

JaySon-Huang
Copy link
Contributor

If we create a table with float devalue value

create table tt(i Int32) engine = Null
alter table tt add column f32 Float32 default 1.234

We get a schema like this: db/metadata/default/tt.sql

ATTACH TABLE tt
(
    i Int32,
    f32 Float32 DEFAULT CAST(Decimal32_1.234 AS Float32)
)
ENGINE = Null

If we stop and start TiFlash again, we get exception when loading table schema from disk

2019.08.23 22:32:12.919765 [ 1 ] <Error> Application: DB::Exception: Cannot create table from metadata file /Users/jayson/Projects
/pingcap/algernon/log/tiflash0/data/db/metadata/default//tt.sql, error: DB::Exception: Unknown identifier: Decimal32_1, stack trac
e:
0. 0   theflash                            0x00000001083d9b1e _ZN10StackTraceC2Ev + 30
1. 1   theflash                            0x00000001083d9b55 _ZN10StackTraceC1Ev + 21
2. 2   theflash                            0x00000001085a1903 _ZN2DB9ExceptionC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi + 83
3. 3   theflash                            0x000000010859e3a3 _ZN2DB9ExceptionC1ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi + 35
4. 4   theflash                            0x000000010fb5f67e _ZN2DB18ExpressionAnalyzer18collectUsedColumnsEv + 3646
5. 5   theflash                            0x000000010fb5b79e _ZN2DB18ExpressionAnalyzerC2ERKNSt3__110shared_ptrINS_4IASTEEERKNS_7ContextERKNS2_INS_8IStorageEEERKNS_17NamesAndTypesListERKNS1_6vectorINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENSL_ISN_EEEEmbRKNS1_13unordered_mapISN_NS_14SubqueryForSetENS1_4hashISN_EENS1_8equal_toISN_EENSL_INS1_4pairIKSN_ST_EEEEEE + 2094
6. 6   theflash                            0x000000010fb603b0 _ZN2DB18ExpressionAnalyzerC1ERKNSt3__110shared_ptrINS_4IASTEEERKNS_7ContextERKNS2_INS_8IStorageEEERKNS_17NamesAndTypesListERKNS1_6vectorINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENSL_ISN_EEEEmbRKNS1_13unordered_mapISN_NS_14SubqueryForSetENS1_4hashISN_EENS1_8equal_toISN_EENSL_INS1_4pairIKSN_ST_EEEEEE + 128
7. 7   theflash                            0x000000010fc331e0 _ZN2DBL12parseColumnsERKNS_17ASTExpressionListERKNS_7ContextE + 2304

This PR make decimal value wrote as a string in CAST statement.

ATTACH TABLE tt
(
    i Int32,
    f32 Float32 DEFAULT CAST('1.234' AS Float32)
)
ENGINE = Null

@JaySon-Huang JaySon-Huang force-pushed the fix_decimal_default_value branch from de6f1e5 to 2c40a88 Compare August 23, 2019 14:41
@JaySon-Huang
Copy link
Contributor Author

/run-integration-tests

Copy link
Member

@hanfei1991 hanfei1991 left a comment

Choose a reason for hiding this comment

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

LGTM

@JaySon-Huang JaySon-Huang force-pushed the fix_decimal_default_value branch from 2c40a88 to 9860e4b Compare August 26, 2019 01:07
@JaySon-Huang
Copy link
Contributor Author

/run-integration-tests

@JaySon-Huang JaySon-Huang merged commit 827de9f into pingcap:master Aug 26, 2019
@JaySon-Huang JaySon-Huang deleted the fix_decimal_default_value branch August 26, 2019 02:41
JaySon-Huang pushed a commit to JaySon-Huang/tiflash that referenced this pull request Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants