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


##########
sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java:
##########
@@ -36,77 +39,200 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 import java.util.function.Function;
 
 /**
- * Annotation to specify desired framework settings.
+ * Specifies current framework settings.
  *
- * This class provides junit rule facilities to build the framework accordingly
- * to the annotation. These rules also cache the previously created frameworks.
+ * Intended usage from tests is via the annotations:
+ *   @SqlTestFrameworkConfig.MinTopNThreshold(33)
+ *
+ * In case of annotations used; it picks up all annotations from:
+ *  * the method
+ *  * its enclosing class and its parents
+ * if none contains a specific setting the default is being taken.
+ *
+ * All configurable setting should have:
+ *   * an annotation with `value` with the desired type
+ *   * the annotation itself should be annotated with itslef to set the 
default value
+ *   * a field should be added to the main config class
  */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface SqlTestFrameworkConfig
+public class SqlTestFrameworkConfig
 {
-  int numMergeBuffers() default 0;
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD, ElementType.TYPE})
+  @NumMergeBuffers(0)
+  public @interface NumMergeBuffers
+  {
+    int value();
+  }
 
-  int minTopNThreshold() default TopNQueryConfig.DEFAULT_MIN_TOPN_THRESHOLD;
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD, ElementType.TYPE})
+  @MinTopNThreshold(TopNQueryConfig.DEFAULT_MIN_TOPN_THRESHOLD)
+  public @interface MinTopNThreshold

Review Comment:
   by using `testBuilder().queryContext()` additional querycontext variables 
can be set (see an example 
[here](https://github.com/apache/druid/blob/dded473ac0a87e67033cd5dbbe67f1c9fa4b335d/sql/src/test/java/org/apache/druid/sql/calcite/CalciteWindowQueryTest.java#L202-L206))
   
   
   looking closer at `TopNQueryConfig` ; there seems to be 2 things:
   * **(A)** there is a `TopNQueryConfig` 
[class](https://github.com/apache/druid/blob/dded473ac0a87e67033cd5dbbe67f1c9fa4b335d/processing/src/main/java/org/apache/druid/query/topn/TopNQueryConfig.java#L34)
 which is jackon serializable
   * **(B)** but `TopNQueryToolChest` also enables a `QueryContext` key to 
override that value 
[here](https://github.com/apache/druid/blob/dded473ac0a87e67033cd5dbbe67f1c9fa4b335d/processing/src/main/java/org/apache/druid/query/topn/TopNQueryQueryToolChest.java#L629-L630)
   
   I think the test system was probably built to configure the `A` approach and 
later probably `B` was also added...
   since querycontext defaults can be configured globally - I think keeping the 
`A` might be redundant ; and it might worth considering the removal of it.
   
   



-- 
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