Support PostgreSQL COLLATION and CONSTRAINT keywords (#31027)
diff --git a/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4 b/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
index 0011b4a..8774b57 100644
--- a/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
+++ b/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
@@ -441,6 +441,8 @@
| JSON
| PARAM
| TABLE
+ | CONSTRAINT
+ | COLLATION
;
typeFuncNameKeyword
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml b/test/it/parser/src/main/resources/case/dml/select.xml
index 7194cd8..2d65a87 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -9377,4 +9377,14 @@
<simple-table name="table1" start-index="19" stop-index="24"/>
</from>
</select>
+
+ <select sql-case-id="select_with_collation_keyword">
+ <projections start-index="7" stop-index="59">
+ <column-projection name="pg_get_expr" start-index="7" stop-index="32" alias="CONSTRAINT"/>
+ <column-projection name="indcollation" start-index="35" stop-index="59" alias="COLLATION"/>
+ </projections>
+ <from start-index="66" stop-index="73">
+ <simple-table name="pg_index" start-index="66" stop-index="73"/>
+ </from>
+ </select>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index e50cc64..4cd3faf 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -276,4 +276,5 @@
<sql-case id="select_with_multi_arbitrary_match" value="SELECT Person1.name AS PersonName, STRING_AGG(Person2.name, '->') WITHIN GROUP (GRAPH PATH) AS Friends, Restaurant.name FROM Person AS Person1, friendOf FOR PATH AS fo, Person FOR PATH AS Person2, likes, Restaurant WHERE MATCH(SHORTEST_PATH(Person1(-(fo)->Person2){1,3}) AND LAST_NODE(Person2)-(likes)->Restaurant ) AND Person1.name = 'Jacob' AND Restaurant.name = 'Ginger and Spice'" db-types="SQLServer"/>
<sql-case id="select_hour_from_table" value="select hour from table1" db-types="SQLServer"/>
<sql-case id="select_minute_from_table" value="select minute from table1" db-types="SQLServer"/>
+ <sql-case id="select_with_collation_keyword" value="SELECT pg_get_expr AS CONSTRAINT ,indcollation AS COLLATION FROM pg_index" db-types="PostgreSQL"/>
</sql-cases>