rohangarg commented on code in PR #15465:
URL: https://github.com/apache/druid/pull/15465#discussion_r1446460548


##########
extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/hll/sql/HllSketchSqlAggregatorTest.java:
##########
@@ -1157,6 +1161,40 @@ public void testHllEstimateAsVirtualColumnWithTopN()
     );
   }
 
+  @SqlTestFrameworkConfig(resultCache = ResultCacheMode.ENABLED)
+  @Test
+  public void testResultCacheWithWindowing()
+  {
+    cannotVectorize();
+    skipVectorize();
+    for (int i = 0; i < 2; i++) {
+      testBuilder()
+          .queryContext(ImmutableMap.of(PlannerContext.CTX_ENABLE_WINDOW_FNS, 
true))
+          .sql(
+              "SELECT "
+                  + " TIME_FLOOR(__time, 'P1D') as dayLvl,\n"
+                  + "  dim1,\n"
+                  + "  HLL_SKETCH_ESTIMATE(DS_HLL(hllsketch_dim1,18,'HLL_4'), 
true),\n"
+                  + "  
HLL_SKETCH_ESTIMATE(DS_HLL(DS_HLL(hllsketch_dim1,18,'HLL_4'),18,'HLL_4') OVER 
(PARTITION BY dim1), true),"
+                  + "  1\n"
+                  + "FROM\n"
+                  + "  (select * from  druid.foo ) ttt\n"
+                  + "  WHERE  __time >= '1903-08-02' AND __time <= 
'2033-08-07'\n"
+                  + "  and dim1 not like '%ikipedia' and l1 > -4\n"
+                  + "  group by 1,2"
+          )
+          .expectedResults(
+              ImmutableList.of(
+                  new Object[] {946684800000L, "", 0.0D, 0.0D, 1},
+                  new Object[] {946771200000L, "10.1", 1.0D, 1.0D, 1},
+                  new Object[] {946857600000L, "2", 1.0D, 1.0D, 1}
+              )
+          )
+          .run();
+      System.out.println("|sad");

Review Comment:
   extra diff



##########
server/src/test/java/org/apache/druid/server/EtagProvider.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.google.inject.BindingAnnotation;
+import com.google.inject.Key;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.TableDataSource;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public interface EtagProvider
+{
+  Key<EtagProvider> KEY = Key.get(EtagProvider.class, 
EtagProvider.Annotation.class);
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD})
+  @BindingAnnotation
+  @interface Annotation
+  {
+  }
+
+  String getEtagFor(Query<?> query);
+
+  class EmptyEtagProvider implements EtagProvider
+  {
+    @Override
+    public String getEtagFor(Query<?> query)
+    {
+      return null;
+    }
+  }
+
+  class AlwaysNewEtagProvider implements EtagProvider

Review Comment:
   this seems unused



##########
sql/src/test/java/org/apache/druid/sql/calcite/util/SqlTestFramework.java:
##########
@@ -391,7 +404,13 @@ public Builder catalogResolver(CatalogResolver 
catalogResolver)
       return this;
     }
 
-    public SqlTestFramework build()
+    public Builder withOverrideModule(Module m)

Review Comment:
   could this method be considered to be added in `QueryComponentSupplier` 
rather? since that interface manages the guice configuration.
   Also, its usages are done right after `configureGuice` 



##########
sql/src/test/java/org/apache/druid/sql/calcite/util/SqlTestFramework.java:
##########
@@ -391,7 +404,13 @@ public Builder catalogResolver(CatalogResolver 
catalogResolver)
       return this;
     }
 
-    public SqlTestFramework build()
+    public Builder withOverrideModule(Module m)

Review Comment:
   I've kinda understood the reason for this change now - 
`QueryComponentSupplier` is per test class right now I think. :( 



##########
sql/src/test/java/org/apache/druid/sql/calcite/util/SqlTestFramework.java:
##########
@@ -550,16 +569,17 @@ public QueryLifecycleFactory queryLifecycleFactory(final 
Injector injector)
   private final AuthorizerMapper authorizerMapper = 
CalciteTests.TEST_AUTHORIZER_MAPPER;
   private final SqlEngine engine;
 
-  private SqlTestFramework(Builder builder)
+  private SqlTestFramework(Builder builder) throws Exception
   {
     this.builder = builder;
     this.componentSupplier = builder.componentSupplier;
+    builder.componentSupplier.beforeNewFrameworkCreateHook();
     Properties properties = new Properties();
     this.componentSupplier.gatherProperties(properties);
     Injector startupInjector = new StartupInjectorBuilder()
         .withProperties(properties)
         .build();
-    DruidInjectorBuilder injectorBuilder = new 
CoreInjectorBuilder(startupInjector)
+    CoreInjectorBuilder injectorBuilder = (CoreInjectorBuilder) new 
CoreInjectorBuilder(startupInjector)

Review Comment:
   nit: cast not needed



##########
sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java:
##########
@@ -103,24 +106,63 @@ public SqlTestFrameworkConfig defaultConfig()
     public Statement apply(Statement base, Description description)
     {
       config = description.getAnnotation(SqlTestFrameworkConfig.class);
+      if (config == null) {
+        config = 
description.getTestClass().getAnnotation(SqlTestFrameworkConfig.class);
+      }
       if (config == null) {
         config = defaultConfig();
       }
-      return base;
+      return new Statement()

Review Comment:
   why not just return base?



##########
sql/src/test/java/org/apache/druid/sql/calcite/util/SqlTestFramework.java:
##########
@@ -170,6 +174,8 @@ default CatalogResolver createCatalogResolver()
     JoinableFactoryWrapper 
createJoinableFactoryWrapper(LookupExtractorFactoryContainerProvider 
lookupProvider);
 
     void finalizeTestFramework(SqlTestFramework sqlTestFramework);
+
+    void beforeNewFrameworkCreateHook() throws Exception;

Review Comment:
   can this named something like `init`? It would be great if we can remove 
this method too altogether. 



##########
server/src/main/java/org/apache/druid/initialization/ServerInjectorBuilder.java:
##########
@@ -106,7 +106,7 @@ public Injector build()
     CoreInjectorBuilder coreBuilder = new CoreInjectorBuilder(childInjector, 
nodeRoles).forServer();
 
     // Override with the per-service modules.
-    ServiceInjectorBuilder serviceBuilder = new 
ServiceInjectorBuilder(coreBuilder).addAll(
+    ServiceInjectorBuilder serviceBuilder = (ServiceInjectorBuilder) new 
ServiceInjectorBuilder(coreBuilder).addAll(

Review Comment:
   nit : don't think we need cast here



##########
sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java:
##########
@@ -633,16 +632,16 @@ public QueryLogHook getQueryLogHook()
   @ClassRule
   public static SqlTestFrameworkConfig.ClassRule queryFrameworkClassRule = new 
SqlTestFrameworkConfig.ClassRule();
 
-  @Rule
+  @Rule(order = 3)

Review Comment:
   why is the order number needed for the test rule?



##########
server/src/test/java/org/apache/druid/server/QueryStackTests.java:
##########
@@ -385,4 +374,22 @@ public static JoinableFactory 
makeJoinableFactoryFromDefault(
 
     return new MapJoinableFactory(setBuilder.build(), mapBuilder.build());
   }
+
+  public static Injector injector()

Review Comment:
   can this be merged with `CalciteTestInjectorBuilder`? 



##########
sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java:
##########
@@ -103,24 +106,63 @@ public SqlTestFrameworkConfig defaultConfig()
     public Statement apply(Statement base, Description description)
     {
       config = description.getAnnotation(SqlTestFrameworkConfig.class);
+      if (config == null) {
+        config = 
description.getTestClass().getAnnotation(SqlTestFrameworkConfig.class);

Review Comment:
   are you planning to use class level configs somewhere in future? 



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