Commit 9a18447
authored
Protobuf compliant translation for supporting richer identifiers for tables and columns (#3696)
This PR makes it possible to have some special characters in the
identifiers of most of the constructs in Relational DDL and enables
querying on them. Since the tables are defined as Descriptor and stored
in DynamicMessage, it is imperative for table and column names to be a
valid symbol in protoBuf, which is limited to a-z, A-Z, 0-9 and _.
Hence, it support (slightly) richer character set, this PR mainly uses
surgical translations over names to make the RecordLayer Type system and
Protobuf types happy.
However, since the Relational Type and RecordLayer type themselves
honour the fact that the Relational name and RecordLayer name should be
the same, the translation spills to the topmost layer and is done quite
preemptively. To alleviate the issue, we might want to have a more
intrinsic understanding of "display" name and "underlying" name.
Another issue, comes from the fact that data flows through the execution
plan in protobuf Dynamic Messages, which makes it imperative for the
query aliases to be protobuf compliant as well!. We could potentially
break out of this by doing some schenanigans around what the recordLayer
type puts into the TypeRepository, but the work here takes a relatively
simpler approach of just making all aliases and user names
protobuf-friendly.
Note that, not all contructs and names are affecting. For example, index
names, schema template names, schema and database names should support
unicode charset out of the box. However, this PR does not really test
around that. I tried testing some part of it - while index names and
schema template names do work, databases naming is restrictive currently
and does not work. So, the scope of this PR is (or, should be)
everything else other than what is mentioned above.
From the implementation POV, the work takes a longer path of doing point
translations in many places rather than just one translation in
IdentifierVisitor to preemptively translate all identifiers. This is
owing to the following reasons:
- We would still want to leave some constructs from this translation -
those that do not require one. We could rather argue that translation
could be done even if not needed. However, this would have complicated
things around customer facing operations like `show`, `describe` items.
- Theoretically, we could very soon drift apart from using protobuf for
runtime data types flowing through plans. Once on it, the scope of
translation would reduce to barely to storage access operators -
supporting the fact that we should not do translations blindly.1 parent 8c089e6 commit 9a18447
File tree
15 files changed
+380
-82
lines changed- fdb-relational-core/src/main
- antlr
- java/com/apple/foundationdb/relational/recordlayer
- ddl
- metadata
- query
- visitors
- yaml-tests/src/test
- java
- resources
15 files changed
+380
-82
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
876 | 876 | | |
877 | 877 | | |
878 | 878 | | |
879 | | - | |
| 879 | + | |
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
| |||
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | 913 | | |
918 | 914 | | |
919 | 915 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
Lines changed: 37 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
| |||
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
58 | 74 | | |
59 | 75 | | |
60 | 76 | | |
| |||
70 | 86 | | |
71 | 87 | | |
72 | 88 | | |
73 | | - | |
74 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
78 | 98 | | |
79 | 99 | | |
80 | 100 | | |
81 | | - | |
| 101 | + | |
82 | 102 | | |
83 | 103 | | |
84 | 104 | | |
85 | 105 | | |
86 | 106 | | |
87 | 107 | | |
88 | 108 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
93 | 113 | | |
94 | 114 | | |
95 | 115 | | |
96 | 116 | | |
97 | 117 | | |
98 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
99 | 127 | | |
100 | 128 | | |
101 | 129 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
145 | 154 | | |
146 | 155 | | |
147 | 156 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
76 | 85 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1343 | 1343 | | |
1344 | 1344 | | |
1345 | 1345 | | |
1346 | | - | |
1347 | | - | |
1348 | | - | |
1349 | | - | |
1350 | | - | |
1351 | | - | |
1352 | 1346 | | |
1353 | 1347 | | |
1354 | 1348 | | |
| |||
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
182 | | - | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| |||
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
340 | | - | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| |||
409 | 410 | | |
410 | 411 | | |
411 | 412 | | |
412 | | - | |
| 413 | + | |
413 | 414 | | |
414 | 415 | | |
415 | 416 | | |
| |||
428 | 429 | | |
429 | 430 | | |
430 | 431 | | |
431 | | - | |
| 432 | + | |
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
| |||
536 | 537 | | |
537 | 538 | | |
538 | 539 | | |
539 | | - | |
| 540 | + | |
540 | 541 | | |
541 | 542 | | |
542 | 543 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1191 | 1191 | | |
1192 | 1192 | | |
1193 | 1193 | | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | 1194 | | |
1201 | 1195 | | |
1202 | 1196 | | |
| |||
0 commit comments