You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "paulo-alves-flttr (via GitHub)" <gi...@apache.org> on 2025/04/15 13:16:56 UTC

[I] Apache Druid Calcite Query Testing: Cannot read field "componentSupplier" because "config" is null (druid)

paulo-alves-flttr opened a new issue, #17920:
URL: https://github.com/apache/druid/issues/17920

   I have an druid extension project that adds new user defined function to Druid SQL, but I have been facing some problems when implementing tests. I have used [this][1] example as reference but it is broken, since *configureGuice* method no longer exists as Druid 32.
   
   
     [1]: https://github.com/implydata/druid-example-extension/blob/master/src/test/java/io/imply/druid/example/calcite/aggregation/ExampleSumSqlAggregationTest.java
   
   I have tried the following by reading the source code from Druid:
   ```
   @ComponentSupplier(MyComponentSupplier.class)
   public class CustomSqlAggregatorTest extends BaseCalciteQueryTest {
   
       @Test
       public void testCustomAggSql() {
           cannotVectorize();
           testBuilder()
                   .sql("select CUSTOM_AGG(m1) from foo")
                   .expectedQueries(
                           List.of(
                                   Druids.newTimeseriesQueryBuilder()
                                           .dataSource(CalciteTests.DATASOURCE1)
                                           .intervals(querySegmentSpec(Filtration.eternity()))
                                           .granularity(Granularities.ALL)
                                           .aggregators(aggregators(getAggFactory()))
                                           .context(QUERY_CONTEXT_DEFAULT)
                                           .build()
                           )
                   )
                   .expectedResults(ImmutableList.of(new Object[]{21.0F}))
                   .run();
       }
       ...
   }
   ```
   But I get the following error:
   ```
   Caused by: java.lang.NullPointerException: Cannot read field "componentSupplier" because "config" is null
   	at org.apache.druid.sql.calcite.SqlTestFrameworkConfig$ConfigurationInstance.<init>(SqlTestFrameworkConfig.java:378)
   	at org.apache.druid.sql.calcite.SqlTestFrameworkConfig$SqlTestFrameworkConfigStore.getConfigurationInstance(SqlTestFrameworkConfig.java:253)
   	at org.apache.druid.sql.calcite.SqlTestFrameworkConfig$Rule.get(SqlTestFrameworkConfig.java:344)
   	at org.apache.druid.sql.calcite.BaseCalciteQueryTest.queryFramework(BaseCalciteQueryTest.java:535)
   	... 34 more
   
   ```
   My component supplier code looks like the following:
   ```
   public class MyComponentSupplier extends SqlTestFramework.StandardComponentSupplier {
       public MyComponentSupplier(TempDirProducer tempDirProducer) {
           super(tempDirProducer);
       }
   
       @Override
       public DruidModule getCoreModule() {
           return DruidModuleCollection.of(
                   super.getCoreModule(),
                   new MyExtensionModule()
           );
       }
   }
   ```
   
   Any suggestions?


-- 
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: commits-unsubscribe@druid.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [I] Apache Druid Calcite Query Testing: Cannot read field "componentSupplier" because "config" is null (druid)

Posted by "paulo-alves-flttr (via GitHub)" <gi...@apache.org>.
paulo-alves-flttr commented on issue #17920:
URL: https://github.com/apache/druid/issues/17920#issuecomment-2831540483

   I was able to get the test running by adding some code before running the test. The code basically forces Component Supplier to be loaded into the config map. The workaround looks like the following:
   
   ```
   @ComponentSupplier(MyComponentSupplier.class)
   public class CustomSqlAggregatorTest extends BaseCalciteQueryTest {
   
       @Test
       public void testCustomAggSql() {
           initializeGuiceConfiguration();
           cannotVectorize();
           testBuilder()
                   .sql("select CUSTOM_AGG(m1) from foo")
                   .expectedQueries(
                           List.of(
                                   Druids.newTimeseriesQueryBuilder()
                                           .dataSource(CalciteTests.DATASOURCE1)
                                           .intervals(querySegmentSpec(Filtration.eternity()))
                                           .granularity(Granularities.ALL)
                                           .aggregators(aggregators(getAggFactory()))
                                           .context(QUERY_CONTEXT_DEFAULT)
                                           .build()
                           )
                   )
                   .expectedResults(ImmutableList.of(new Object[]{21.0F}))
                   .run();
       }
       
       private static void initializeGuiceConfiguration() {
           List<Annotation> annotations = List.of(ArrayWithLimitSqlAggregatorTest.class.getAnnotations());
           queryFrameworkRule.setConfig(new SqlTestFrameworkConfig(annotations));
       }
       ...
   }
   ```
   
   For some reason @ComponentSupplier annotation doesn't seems to be working properly and I couldn't figure out the configuration needed for it to work as it should.


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [I] Apache Druid Calcite Query Testing: Cannot read field "componentSupplier" because "config" is null (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on issue #17920:
URL: https://github.com/apache/druid/issues/17920#issuecomment-2841377812

   this was very evil...the junit5 extension initialization was silently skipped due to the fact that the `@Test` annotations were coming from junit4 - and it have lead to the strange error you've seen.
   
   I've opened a PR to upgrade the example to 33.0.0
   
   https://github.com/implydata/druid-example-extension/pull/12


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [I] Apache Druid Calcite Query Testing: Cannot read field "componentSupplier" because "config" is null (druid)

Posted by "paulo-alves-flttr (via GitHub)" <gi...@apache.org>.
paulo-alves-flttr closed issue #17920: Apache Druid Calcite Query Testing: Cannot read field "componentSupplier" because "config" is null
URL: https://github.com/apache/druid/issues/17920


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [I] Apache Druid Calcite Query Testing: Cannot read field "componentSupplier" because "config" is null (druid)

Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm commented on issue #17920:
URL: https://github.com/apache/druid/issues/17920#issuecomment-2836067156

   Thank you for posting what worked for you. Tagging @kgyrtkirk, who has done work in this area recently, in case there is some problem with `@ComponentSupplier`.


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org