Repository navigation
Commit 9fc1980
fix: allow keywords after a dot in Snowflake JSON paths and link their AST nodes
The previous commit lets a keyword name the first element after ":" in a
JSON path. A keyword further along the path still threw a ParseException:
SELECT v:a.output, v:a.b.from::INT, v:a[0].from.x[1] FROM t
The expression parser reads v:a.output as a qualified column name, and a
qualified name does not accept a keyword as a part. JsonPathElement now
also looks ahead with isJsonPathWithKeywordAfterDot(), which walks the
identifiers, dots and [...] subscripts of the path and reports whether a
keyword follows a ".". If so, JsonPathKeyword parses the path, with a new
JsonPathStep production taking a keyword after "." as an element name.
isKeywordJsonPathName() shares its keyword test with it through
isKeywordWord(). A word followed by "(" stays a function call, and
t.output outside a JSON path is still rejected.
JsonPathKeyword also left the last step or cast of a path without an AST
node, for example the cast in v:select::INT or v:from::INT + 1. It linked
the previous element before building each step, so the one built last was
never linked. ASTNodeCoverageTest did not notice, as it only walks the SQL
resources. Each step and cast is now linked where it is built, and the
keyword-path cases are added to testStatementsTheCorpusLacks.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>1 parent e125308 commit 9fc1980
3 files changed
Lines changed: 114 additions & 9 deletions
File tree
- src
- main/jjtree/net/sf/jsqlparser/parser
- test/java/net/sf/jsqlparser
- expression
- parser
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1093 | 1093 | | |
1094 | 1094 | | |
1095 | 1095 | | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1100 | 1107 | | |
1101 | 1108 | | |
1102 | 1109 | | |
1103 | | - | |
| 1110 | + | |
1104 | 1111 | | |
1105 | 1112 | | |
1106 | 1113 | | |
| |||
1111 | 1118 | | |
1112 | 1119 | | |
1113 | 1120 | | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
1114 | 1166 | | |
1115 | 1167 | | |
1116 | 1168 | | |
| |||
14976 | 15028 | | |
14977 | 15029 | | |
14978 | 15030 | | |
14979 | | - | |
| 15031 | + | |
14980 | 15032 | | |
14981 | 15033 | | |
14982 | 15034 | | |
| |||
15004 | 15056 | | |
15005 | 15057 | | |
15006 | 15058 | | |
15007 | | - | |
| 15059 | + | |
15008 | 15060 | | |
15009 | | - | |
| 15061 | + | |
15010 | 15062 | | |
15011 | 15063 | | |
15012 | 15064 | | |
15013 | 15065 | | |
15014 | | - | |
| 15066 | + | |
15015 | 15067 | | |
15016 | 15068 | | |
15017 | 15069 | | |
| |||
15020 | 15072 | | |
15021 | 15073 | | |
15022 | 15074 | | |
| 15075 | + | |
| 15076 | + | |
| 15077 | + | |
| 15078 | + | |
| 15079 | + | |
| 15080 | + | |
| 15081 | + | |
| 15082 | + | |
| 15083 | + | |
| 15084 | + | |
| 15085 | + | |
| 15086 | + | |
| 15087 | + | |
| 15088 | + | |
| 15089 | + | |
| 15090 | + | |
| 15091 | + | |
15023 | 15092 | | |
15024 | 15093 | | |
15025 | 15094 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
115 | 145 | | |
116 | 146 | | |
117 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
174 | 180 | | |
175 | 181 | | |
176 | 182 | | |
| |||
0 commit comments