Skip to content

Commit

Permalink
Parse SRID attribute for virtual columns
Browse files Browse the repository at this point in the history
The parser is missing support to parse the SRID attribute for a virtual
column. This adds the logic.

Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Feb 1, 2025
1 parent cb7d61a commit 0ebed1f
Show file tree
Hide file tree
Showing 3 changed files with 8,978 additions and 8,960 deletions.
4 changes: 4 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5975,6 +5975,10 @@ partition by range (YEAR(purchased)) subpartition by hash (TO_DAYS(purchased))
input: "create table t (id int, vec VECTOR(4))",
output: "create table t (\n\tid int,\n\tvec VECTOR(4)\n)",
},
{
input: "CREATE TABLE `locations` (`geocode` json DEFAULT NULL, `lat_long` point GENERATED ALWAYS AS (point(json_unquote(json_extract(`geocode`,_utf8mb4'$.geometry.location.lat')),json_unquote(json_extract(`geocode`,_utf8mb4'$.geometry.location.lng')))) VIRTUAL /*!80003 SRID 4326 */) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci",
output: "create table locations (\n\tgeocode json default null,\n\tlat_long point as (point(json_unquote(json_extract(geocode, _utf8mb4 '$.geometry.location.lat')), json_unquote(json_extract(geocode, _utf8mb4 '$.geometry.location.lng')))) virtual srid 4326\n) ENGINE InnoDB,\n CHARSET utf8mb4,\n COLLATE utf8mb4_0900_ai_ci",
},
}
parser := NewTestParser()
for _, test := range createTableQueries {
Expand Down
Loading

0 comments on commit 0ebed1f

Please sign in to comment.