Skip to content

Commit 6e78e18

Browse files
authored
[MySql] Support convert to double/float type for cast/convert function (#3858)
1 parent c1e4b59 commit 6e78e18

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

sql/mysql/Positive-Technologies/MySqlParser.g4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,9 +2288,9 @@ collectionOptions
22882288
convertedDataType
22892289
:
22902290
(
2291-
typeName=(BINARY| NCHAR) lengthOneDimension?
2291+
typeName=(BINARY | NCHAR | FLOAT) lengthOneDimension?
22922292
| typeName=CHAR lengthOneDimension? (charSet charsetName)?
2293-
| typeName=(DATE | DATETIME | TIME | JSON | INT | INTEGER)
2293+
| typeName=(DATE | DATETIME | TIME | YEAR | JSON | INT | INTEGER | DOUBLE)
22942294
| typeName=(DECIMAL | DEC) lengthTwoOptionalDimension?
22952295
| (SIGNED | UNSIGNED) (INTEGER | INT)?
22962296
) ARRAY?

sql/mysql/Positive-Technologies/examples/ddl_alter.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
alter table ship_class add column ship_spec varchar(150) first, add somecol int after start_build;
44
alter table t3 add column (c2 decimal(10, 2) comment 'comment`' null, c3 enum('abc', 'cba', 'aaa')), add index t3_i1 using btree (c2) comment 'some index';
55
alter table t3 add column (c2 decimal(10, 2), c3 int);
6+
ALTER TABLE `deals` ADD INDEX `idx_custom_field_30c4f4a7c529ccf0825b2fac732bebfd843ed764` ((cast(json_unquote(json_extract(`custom_fields`,_utf8mb4'$."30c4f4a7c529ccf0825b2fac732bebfd843ed764".value')) as DOUBLE)));
7+
ALTER TABLE `deals` ADD INDEX `idx_custom_field_30c4f4a7c529ccf0825b2fac732bebfd843ed764` ((cast(json_unquote(json_extract(`custom_fields`,_utf8mb4'$."30c4f4a7c529ccf0825b2fac732bebfd843ed764".value')) as FLOAT)));
68
alter table t3 alter index t3_i1 invisible;
79
alter table t3 alter index t3_i1 visible;
810
alter table t3 rename index t3_i1 to t3_i2;

sql/mysql/Positive-Technologies/examples/ddl_create.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ create index index5 on antlr_tokens(token(30) asc) algorithm default;
287287
create index index6 on antlr_tokens(token(30) asc) algorithm default lock default;
288288
create index index7 on antlr_tokens(token(30) asc) lock default algorithm default;
289289
create index index8 on t1(col1) comment 'test index' using btree;
290+
CREATE INDEX `idx_custom_field_30c4f4a7c529ccf0825b2fac732bebfd843ed764` ON `deals` ((cast(json_unquote(json_extract(`custom_fields`,_utf8mb4'$."30c4f4a7c529ccf0825b2fac732bebfd843ed764".value')) as double)));
291+
CREATE INDEX `idx_custom_field_d3bb7ad91ba729aaa20df0af037cb7ed8ce3ffc8` ON `deals` ((cast(json_unquote(json_extract(`custom_fields`,_utf8mb4'$."d3bb7ad91ba729aaa20df0af037cb7ed8ce3ffc8".value')) as float)));
290292
#end
291293
#begin
292294
-- Create logfile group

0 commit comments

Comments
 (0)