kgyrtkirk commented on code in PR #16260:
URL: https://github.com/apache/druid/pull/16260#discussion_r1562501886


##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java:
##########
@@ -88,6 +101,39 @@ public class DruidSqlValidator extends BaseDruidSqlValidator
 
   private final PlannerContext plannerContext;
 
+  // This part is a bit sad. By the time we get here, the validator will have 
created
+  // the ORDER BY namespace if we had a real ORDER BY. We have to "catch up" 
and do the
+  // work that registerQuery() should have done. That's kind of OK. But, the 
orderScopes
+  // variable is private, so we have to play dirty tricks to get at it.
+  //
+  // Warning: this may no longer work if Java forbids access to private fields 
in a
+  // future release.
+  private static final Field CLAUSE_SCOPES_FIELD;
+  private static final Object ORDER_CLAUSE;
+
+  static {
+    try {
+      CLAUSE_SCOPES_FIELD = FieldUtils.getDeclaredField(
+          SqlValidatorImpl.class,
+          "clauseScopes",
+          true
+      );
+    }
+    catch (RuntimeException e) {
+      throw new ISE(e, "SqlValidatorImpl.clauseScopes is not accessible");
+    }
+
+    try {
+      Class<?> innerClass = 
Class.forName("org.apache.calcite.sql.validate.SqlValidatorImpl$Clause");
+      Method method = innerClass.getMethod("valueOf", Class.class, 
String.class);
+      method.setAccessible(true);
+      ORDER_CLAUSE = method.invoke(null, innerClass, "ORDER");

Review Comment:
   this means we are not anymore use the api - instead open up a field via 
reflection; there must be a better way.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to