1- package io .substrait .isthmus . operation ;
1+ package io .substrait .isthmus ;
22
33import io .substrait .relation .Aggregate ;
44import io .substrait .relation .ConsistentPartitionWindow ;
@@ -43,7 +43,7 @@ public class SqlKindFromRel
4343 @ Override
4444 public SqlKind visit (Aggregate aggregate , EmptyVisitationContext context )
4545 throws RuntimeException {
46- // Aggregation is a core part of a query (DQL).
46+
4747 return QUERY_KIND ;
4848 }
4949
@@ -56,25 +56,21 @@ public SqlKind visit(EmptyScan emptyScan, EmptyVisitationContext context)
5656
5757 @ Override
5858 public SqlKind visit (Fetch fetch , EmptyVisitationContext context ) throws RuntimeException {
59- // Fetch corresponds to LIMIT/OFFSET, a part of a query.
6059 return QUERY_KIND ;
6160 }
6261
6362 @ Override
6463 public SqlKind visit (Filter filter , EmptyVisitationContext context ) throws RuntimeException {
65- // Filter corresponds to a WHERE clause, a part of a query.
6664 return QUERY_KIND ;
6765 }
6866
6967 @ Override
7068 public SqlKind visit (Join join , EmptyVisitationContext context ) throws RuntimeException {
71- // A logical join operation.
7269 return SqlKind .JOIN ;
7370 }
7471
7572 @ Override
7673 public SqlKind visit (Set set , EmptyVisitationContext context ) throws RuntimeException {
77- // Maps Substrait's Set operations to their SQL equivalents.
7874 switch (set .getSetOp ()) {
7975 case UNION_ALL :
8076 case UNION_DISTINCT :
@@ -96,38 +92,32 @@ public SqlKind visit(Set set, EmptyVisitationContext context) throws RuntimeExce
9692 @ Override
9793 public SqlKind visit (NamedScan namedScan , EmptyVisitationContext context )
9894 throws RuntimeException {
99- // A scan from a named table is the start of a query.
10095 return QUERY_KIND ;
10196 }
10297
10398 @ Override
10499 public SqlKind visit (LocalFiles localFiles , EmptyVisitationContext context )
105100 throws RuntimeException {
106- // A scan from local files is a type of query input.
107101 return QUERY_KIND ;
108102 }
109103
110104 @ Override
111105 public SqlKind visit (Project project , EmptyVisitationContext context ) throws RuntimeException {
112- // Project corresponds to the SELECT clause of a query.
113106 return QUERY_KIND ;
114107 }
115108
116109 @ Override
117110 public SqlKind visit (Expand expand , EmptyVisitationContext context ) throws RuntimeException {
118- // Expand is a relational operator used in queries (e.g., for grouping sets).
119111 return QUERY_KIND ;
120112 }
121113
122114 @ Override
123115 public SqlKind visit (Sort sort , EmptyVisitationContext context ) throws RuntimeException {
124- // A sort operation directly maps to ORDER BY.
125116 return SqlKind .ORDER_BY ;
126117 }
127118
128119 @ Override
129120 public SqlKind visit (Cross cross , EmptyVisitationContext context ) throws RuntimeException {
130- // A cross join is a type of join.
131121 return SqlKind .JOIN ;
132122 }
133123
@@ -141,62 +131,53 @@ public SqlKind visit(VirtualTableScan virtualTableScan, EmptyVisitationContext c
141131 @ Override
142132 public SqlKind visit (ExtensionLeaf extensionLeaf , EmptyVisitationContext context )
143133 throws RuntimeException {
144- // Unknown extension node.
145134 return SqlKind .OTHER ;
146135 }
147136
148137 @ Override
149138 public SqlKind visit (ExtensionSingle extensionSingle , EmptyVisitationContext context )
150139 throws RuntimeException {
151- // Unknown extension node.
152140 return SqlKind .OTHER ;
153141 }
154142
155143 @ Override
156144 public SqlKind visit (ExtensionMulti extensionMulti , EmptyVisitationContext context )
157145 throws RuntimeException {
158- // Unknown extension node.
159146 return SqlKind .OTHER ;
160147 }
161148
162149 @ Override
163150 public SqlKind visit (ExtensionTable extensionTable , EmptyVisitationContext context )
164151 throws RuntimeException {
165- // Unknown extension node.
166152 return SqlKind .OTHER ;
167153 }
168154
169155 @ Override
170156 public SqlKind visit (HashJoin hashJoin , EmptyVisitationContext context ) throws RuntimeException {
171- // A physical hash join is a type of join.
172157 return SqlKind .JOIN ;
173158 }
174159
175160 @ Override
176161 public SqlKind visit (MergeJoin mergeJoin , EmptyVisitationContext context )
177162 throws RuntimeException {
178- // A physical merge join is a type of join.
179163 return SqlKind .JOIN ;
180164 }
181165
182166 @ Override
183167 public SqlKind visit (NestedLoopJoin nestedLoopJoin , EmptyVisitationContext context )
184168 throws RuntimeException {
185- // A physical nested loop join is a type of join.
186169 return SqlKind .JOIN ;
187170 }
188171
189172 @ Override
190173 public SqlKind visit (
191174 ConsistentPartitionWindow consistentPartitionWindow , EmptyVisitationContext context )
192175 throws RuntimeException {
193- // This relation represents a window function operation.
194176 return SqlKind .OVER ;
195177 }
196178
197179 @ Override
198180 public SqlKind visit (NamedWrite write , EmptyVisitationContext context ) throws RuntimeException {
199- // DML and CTAS write operations.
200181 switch (write .getOperation ()) {
201182 case INSERT :
202183 return SqlKind .INSERT ;
@@ -214,13 +195,11 @@ public SqlKind visit(NamedWrite write, EmptyVisitationContext context) throws Ru
214195 @ Override
215196 public SqlKind visit (ExtensionWrite write , EmptyVisitationContext context )
216197 throws RuntimeException {
217- // Custom DML/DDL operations are best mapped to OTHER or OTHER_DDL.
218198 return SqlKind .OTHER_DDL ;
219199 }
220200
221201 @ Override
222202 public SqlKind visit (NamedDdl ddl , EmptyVisitationContext context ) throws RuntimeException {
223- // DDL operations, determined by combining the operation and the object type.
224203 switch (ddl .getOperation ()) {
225204 case CREATE :
226205 case CREATE_OR_REPLACE :
@@ -251,14 +230,11 @@ public SqlKind visit(NamedDdl ddl, EmptyVisitationContext context) throws Runtim
251230
252231 @ Override
253232 public SqlKind visit (ExtensionDdl ddl , EmptyVisitationContext context ) throws RuntimeException {
254- // A custom DDL operation.
255233 return SqlKind .OTHER_DDL ;
256234 }
257235
258236 @ Override
259237 public SqlKind visit (NamedUpdate update , EmptyVisitationContext context ) throws RuntimeException {
260- // An update operation is a specific DML type. Note that modern Substrait
261- // producers should use NamedWrite with WriteOp.UPDATE instead.
262238 return SqlKind .UPDATE ;
263239 }
264240}
0 commit comments