Skip to content

Commit 69dfbf7

Browse files
authored
Improve the parsing of methods in MySQL and Doris (#32789)
* Improve the parsing of geo methods in MySQL * check in Doris * remove useless xml node * remove useless xml node
1 parent 1a41252 commit 69dfbf7

File tree

2 files changed

+255
-2
lines changed

2 files changed

+255
-2
lines changed

test/it/parser/src/main/resources/case/dml/select-special-function.xml

Lines changed: 242 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,6 @@
23222322
</projections>
23232323
</select>
23242324

2325-
// <sql-case id="select_export_set" value="SELECT EXPORT_SET(5,'Y','N',',',4)" db-types="MySQL" />
23262325
<select sql-case-id="select_export_set">
23272326
<projections start-index="7" stop-index="33">
23282327
<expression-projection start-index="7" stop-index="33" text="EXPORT_SET(5,'Y','N',',',4)">
@@ -2402,7 +2401,7 @@
24022401
</expression-projection>
24032402
</projections>
24042403
</select>
2405-
<sql-case id="select_first_value" value="SELECT FIRST_VALUE(name) OVER (ORDER BY id) FROM t_order" db-types="MySQL" />
2404+
24062405
<select sql-case-id="select_first_value">
24072406
<projections start-index="7" stop-index="42">
24082407
<expression-projection start-index="7" stop-index="42" text="FIRST_VALUE(name) OVER (ORDER BY id)">
@@ -3890,4 +3889,245 @@
38903889
</expression-projection>
38913890
</projections>
38923891
</select>
3892+
3893+
<select sql-case-id="select_soundex">
3894+
<projections start-index="7" stop-index="22">
3895+
<expression-projection start-index="7" stop-index="22" text="SOUNDEX('Hello')">
3896+
<expr>
3897+
<function start-index="7" stop-index="22" function-name="SOUNDEX" text="SOUNDEX('Hello')">
3898+
<parameter>
3899+
<literal-expression start-index="15" stop-index="21" value="Hello" />
3900+
</parameter>
3901+
</function>
3902+
</expr>
3903+
</expression-projection>
3904+
</projections>
3905+
</select>
3906+
3907+
<select sql-case-id="select_space">
3908+
<projections start-index="7" stop-index="14">
3909+
<expression-projection start-index="7" stop-index="14" text="SPACE(6)">
3910+
<expr>
3911+
<function start-index="7" stop-index="14" function-name="SPACE" text="SPACE(6)">
3912+
<parameter>
3913+
<literal-expression start-index="13" stop-index="13" value="6" />
3914+
</parameter>
3915+
</function>
3916+
</expr>
3917+
</expression-projection>
3918+
</projections>
3919+
</select>
3920+
3921+
<select sql-case-id="select_sqrt">
3922+
<projections start-index="7" stop-index="13">
3923+
<expression-projection start-index="7" stop-index="13" text="SQRT(4)">
3924+
<expr>
3925+
<function start-index="7" stop-index="13" function-name="SQRT" text="SQRT(4)">
3926+
<parameter>
3927+
<literal-expression start-index="12" stop-index="12" value="4" />
3928+
</parameter>
3929+
</function>
3930+
</expr>
3931+
</expression-projection>
3932+
</projections>
3933+
</select>
3934+
3935+
<select sql-case-id="select_st_area">
3936+
<projections start-index="7" stop-index="78">
3937+
<expression-projection start-index="7" stop-index="78" text="ST_Area(ST_GeomFromText('Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'))">
3938+
<expr>
3939+
<function start-index="7" stop-index="78" function-name="ST_Area" text="ST_Area(ST_GeomFromText('Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'))">
3940+
<parameter>
3941+
<function start-index="15" stop-index="77" function-name="ST_GeomFromText" text="ST_GeomFromText('Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))')" >
3942+
<parameter>
3943+
<literal-expression start-index="31" stop-index="76" value="Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))" />
3944+
</parameter>
3945+
</function>
3946+
</parameter>
3947+
</function>
3948+
</expr>
3949+
</expression-projection>
3950+
</projections>
3951+
</select>
3952+
3953+
<select sql-case-id="select_st_asbinary">
3954+
<projections start-index="7" stop-index="30">
3955+
<expression-projection start-index="7" stop-index="30" text="ST_AsBinary(POINT(1, 1))">
3956+
<expr>
3957+
<function start-index="7" stop-index="30" function-name="ST_AsBinary" text="ST_AsBinary(POINT(1, 1))">
3958+
<parameter>
3959+
<function start-index="19" stop-index="29" function-name="POINT" text="POINT(1, 1)" >
3960+
<parameter>
3961+
<literal-expression start-index="25" stop-index="25" value="1"/>
3962+
</parameter>
3963+
<parameter>
3964+
<literal-expression start-index="28" stop-index="28" value="1"/>
3965+
</parameter>
3966+
</function>
3967+
</parameter>
3968+
</function>
3969+
</expr>
3970+
</expression-projection>
3971+
</projections>
3972+
</select>
3973+
3974+
<select sql-case-id="select_st_asgeojson">
3975+
<projections start-index="7" stop-index="65">
3976+
<expression-projection start-index="7" stop-index="65" text="ST_AsGeoJSON(ST_GeomFromText('POINT(11.11111 12.22222)'),2)">
3977+
<expr>
3978+
<function start-index="7" stop-index="65" function-name="ST_AsGeoJSON" text="ST_AsGeoJSON(ST_GeomFromText('POINT(11.11111 12.22222)'),2)">
3979+
<parameter>
3980+
<function start-index="20" stop-index="62" function-name="ST_GeomFromText" text="ST_GeomFromText('POINT(11.11111 12.22222)')" >
3981+
<parameter>
3982+
<literal-expression start-index="36" stop-index="61" value="POINT(11.11111 12.22222)"/>
3983+
</parameter>
3984+
</function>
3985+
</parameter>
3986+
<parameter>
3987+
<literal-expression start-index="64" stop-index="64" value="2"/>
3988+
</parameter>
3989+
</function>
3990+
</expr>
3991+
</expression-projection>
3992+
</projections>
3993+
</select>
3994+
3995+
<select sql-case-id="select_st_astext">
3996+
<projections start-index="7" stop-index="59">
3997+
<expression-projection start-index="7" stop-index="59" text="ST_AsText(ST_GeomFromText('LineString(1 1,2 2,3 3)'))">
3998+
<expr>
3999+
<function start-index="7" stop-index="59" function-name="ST_AsText" text="ST_AsText(ST_GeomFromText('LineString(1 1,2 2,3 3)'))">
4000+
<parameter>
4001+
<function start-index="17" stop-index="58" function-name="ST_GeomFromText" text="ST_GeomFromText('LineString(1 1,2 2,3 3)')" >
4002+
<parameter>
4003+
<literal-expression start-index="33" stop-index="57" value="LineString(1 1,2 2,3 3)"/>
4004+
</parameter>
4005+
</function>
4006+
</parameter>
4007+
</function>
4008+
</expr>
4009+
</expression-projection>
4010+
</projections>
4011+
</select>
4012+
4013+
<select sql-case-id="select_st_buffer">
4014+
<projections start-index="7" stop-index="49">
4015+
<expression-projection start-index="7" stop-index="49" text="ST_Buffer(ST_GeomFromText('POINT(0 0)'), 0)">
4016+
<expr>
4017+
<function start-index="7" stop-index="49" function-name="ST_Buffer" text="ST_Buffer(ST_GeomFromText('POINT(0 0)'), 0)">
4018+
<parameter>
4019+
<function start-index="17" stop-index="45" function-name="ST_GeomFromText" text="ST_GeomFromText('POINT(0 0)')" >
4020+
<parameter>
4021+
<literal-expression start-index="33" stop-index="44" value="POINT(0 0)"/>
4022+
</parameter>
4023+
</function>
4024+
</parameter>
4025+
<parameter>
4026+
<literal-expression start-index="48" stop-index="48" value="0"/>
4027+
</parameter>
4028+
</function>
4029+
</expr>
4030+
</expression-projection>
4031+
</projections>
4032+
</select>
4033+
4034+
<select sql-case-id="select_st_buffer_strategy">
4035+
<projections start-index="7" stop-index="36">
4036+
<expression-projection start-index="7" stop-index="36" text="ST_Buffer_Strategy('end_flat')">
4037+
<expr>
4038+
<function start-index="7" stop-index="36" function-name="ST_Buffer_Strategy" text="ST_Buffer_Strategy('end_flat')">
4039+
<parameter>
4040+
<literal-expression start-index="26" stop-index="35" value="end_flat"/>
4041+
</parameter>
4042+
</function>
4043+
</expr>
4044+
</expression-projection>
4045+
</projections>
4046+
</select>
4047+
4048+
<select sql-case-id="select_st_centroid">
4049+
<projections start-index="7" stop-index="68">
4050+
<expression-projection start-index="7" stop-index="68" text="ST_Centroid(ST_GeomFromText('POLYGON((0 0,0 3,3 3,3 0,0 0))'))">
4051+
<expr>
4052+
<function start-index="7" stop-index="68" function-name="ST_Centroid" text="ST_Centroid(ST_GeomFromText('POLYGON((0 0,0 3,3 3,3 0,0 0))'))">
4053+
<parameter>
4054+
<function start-index="19" stop-index="67" function-name="ST_GeomFromText" text="ST_GeomFromText('POLYGON((0 0,0 3,3 3,3 0,0 0))')" >
4055+
<parameter>
4056+
<literal-expression start-index="35" stop-index="66" value="POLYGON((0 0,0 3,3 3,3 0,0 0))"/>
4057+
</parameter>
4058+
</function>
4059+
</parameter>
4060+
</function>
4061+
</expr>
4062+
</expression-projection>
4063+
</projections>
4064+
</select>
4065+
4066+
<select sql-case-id="select_st_contains">
4067+
<projections start-index="7" stop-index="79">
4068+
<expression-projection start-index="7" stop-index="79" text="ST_Contains(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(2 1)'))">
4069+
<expr>
4070+
<function start-index="7" stop-index="79" function-name="ST_Contains" text="ST_Contains(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(2 1)'))">
4071+
<parameter>
4072+
<function start-index="19" stop-index="47" function-name="ST_GeomFromText" text="ST_GeomFromText('POINT(1 1)')" >
4073+
<parameter>
4074+
<literal-expression start-index="35" stop-index="46" value="POINT(1 1)"/>
4075+
</parameter>
4076+
</function>
4077+
</parameter>
4078+
<parameter>
4079+
<function start-index="50" stop-index="78" function-name="ST_GeomFromText" text="ST_GeomFromText('POINT(2 1)')" >
4080+
<parameter>
4081+
<literal-expression start-index="66" stop-index="77" value="POINT(2 1)"/>
4082+
</parameter>
4083+
</function>
4084+
</parameter>
4085+
</function>
4086+
</expr>
4087+
</expression-projection>
4088+
</projections>
4089+
</select>
4090+
4091+
<select sql-case-id="select_st_convexhull">
4092+
<projections start-index="7" stop-index="72">
4093+
<expression-projection start-index="7" stop-index="72" text="ST_ConvexHull(ST_GeomFromText('MULTIPOINT(5 0,25 0,15 10,15 25)'))">
4094+
<expr>
4095+
<function start-index="7" stop-index="72" function-name="ST_ConvexHull" text="ST_ConvexHull(ST_GeomFromText('MULTIPOINT(5 0,25 0,15 10,15 25)'))">
4096+
<parameter>
4097+
<function start-index="21" stop-index="71" function-name="ST_GeomFromText" text="ST_GeomFromText('MULTIPOINT(5 0,25 0,15 10,15 25)')" >
4098+
<parameter>
4099+
<literal-expression start-index="37" stop-index="70" value="MULTIPOINT(5 0,25 0,15 10,15 25)"/>
4100+
</parameter>
4101+
</function>
4102+
</parameter>
4103+
</function>
4104+
</expr>
4105+
</expression-projection>
4106+
</projections>
4107+
</select>
4108+
4109+
<select sql-case-id="select_st_crosses">
4110+
<projections start-index="7" stop-index="78">
4111+
<expression-projection start-index="7" stop-index="78" text="ST_Crosses(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(2 2)'))">
4112+
<expr>
4113+
<function start-index="7" stop-index="78" function-name="ST_Crosses" text="ST_Crosses(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(2 2)'))">
4114+
<parameter>
4115+
<function start-index="18" stop-index="46" function-name="ST_GeomFromText" text="ST_GeomFromText('POINT(1 1)')" >
4116+
<parameter>
4117+
<literal-expression start-index="34" stop-index="45" value="POINT(1 1)"/>
4118+
</parameter>
4119+
</function>
4120+
</parameter>
4121+
<parameter>
4122+
<function start-index="49" stop-index="77" function-name="ST_GeomFromText" text="ST_GeomFromText('POINT(2 2)')" >
4123+
<parameter>
4124+
<literal-expression start-index="65" stop-index="76" value="POINT(2 2)"/>
4125+
</parameter>
4126+
</function>
4127+
</parameter>
4128+
</function>
4129+
</expr>
4130+
</expression-projection>
4131+
</projections>
4132+
</select>
38934133
</sql-parser-test-cases>

test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,17 @@
225225
<sql-case id="select_st_geometryn" value="SELECT ST_GeometryN(ST_GeomFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))'),1)" db-types="MySQL" />
226226
<sql-case id="select_st_geometrytype" value="SELECT ST_GeometryType(ST_GeomFromText('POINT(1 1)'))" db-types="MySQL" />
227227
<sql-case id="select_st_geomfromgeojson" value="SELECT ST_GeomFromGeoJSON('{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[102.0, 0.0]}')" db-types="MySQL" />
228+
<sql-case id="select_soundex" value="SELECT SOUNDEX('Hello')" db-types="MySQL,Doris" />
229+
<sql-case id="select_space" value="SELECT SPACE(6)" db-types="MySQL,Doris" />
230+
<sql-case id="select_sqrt" value="SELECT SQRT(4)" db-types="MySQL,Doris" />
231+
<sql-case id="select_st_area" value="SELECT ST_Area(ST_GeomFromText('Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'))" db-types="MySQL,Doris" />
232+
<sql-case id="select_st_asbinary" value="SELECT ST_AsBinary(POINT(1, 1))" db-types="MySQL,Doris" />
233+
<sql-case id="select_st_asgeojson" value="SELECT ST_AsGeoJSON(ST_GeomFromText('POINT(11.11111 12.22222)'),2)" db-types="MySQL,Doris" />
234+
<sql-case id="select_st_astext" value="SELECT ST_AsText(ST_GeomFromText('LineString(1 1,2 2,3 3)'))" db-types="MySQL,Doris" />
235+
<sql-case id="select_st_buffer" value="SELECT ST_Buffer(ST_GeomFromText('POINT(0 0)'), 0)" db-types="MySQL,Doris" />
236+
<sql-case id="select_st_buffer_strategy" value="SELECT ST_Buffer_Strategy('end_flat')" db-types="MySQL,Doris" />
237+
<sql-case id="select_st_centroid" value="SELECT ST_Centroid(ST_GeomFromText('POLYGON((0 0,0 3,3 3,3 0,0 0))'))" db-types="MySQ,Doris" />
238+
<sql-case id="select_st_contains" value="SELECT ST_Contains(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(2 1)'))" db-types="MySQL,Doris" />
239+
<sql-case id="select_st_convexhull" value="SELECT ST_ConvexHull(ST_GeomFromText('MULTIPOINT(5 0,25 0,15 10,15 25)'))" db-types="MySQL,Doris" />
240+
<sql-case id="select_st_crosses" value="SELECT ST_Crosses(ST_GeomFromText('POINT(1 1)'), ST_GeomFromText('POINT(2 2)'))" db-types="MySQL,Doris" />
228241
</sql-cases>

0 commit comments

Comments
 (0)