Skip to content

Commit

Permalink
use lower_camel for config names
Browse files Browse the repository at this point in the history
  • Loading branch information
kgyrtkirk committed May 17, 2024
1 parent 94f9386 commit 652cc20
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.druid.sql.calcite;

import com.google.common.base.CaseFormat;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
Expand Down Expand Up @@ -156,10 +157,10 @@ public Class<? extends QueryComponentSupplier> fromString(String name) throws Ex
}

private static final Set<String> KNOWN_CONFIG_KEYS = ImmutableSet.<String>builder()
.add(NumMergeBuffers.class.getSimpleName())
.add(MinTopNThreshold.class.getSimpleName())
.add(ResultCache.class.getSimpleName())
.add(ComponentSupplier.class.getSimpleName())
.add(NumMergeBuffers.PROCESSOR.getConfigName())
.add(MinTopNThreshold.PROCESSOR.getConfigName())
.add(ResultCache.PROCESSOR.getConfigName())
.add(ComponentSupplier.PROCESSOR.getConfigName())
.build();

public final int numMergeBuffers;
Expand Down Expand Up @@ -408,6 +409,11 @@ public ConfigOptionProcessor(Class<? extends Annotation> annotationClass)
this.annotationClass = annotationClass;
}

public final String getConfigName()
{
return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, annotationClass.getSimpleName());
}

@SuppressWarnings("unchecked")
public final T fromAnnotations(List<Annotation> annotations) throws Exception
{
Expand Down Expand Up @@ -436,7 +442,7 @@ public final T defaultValue() throws Exception

public final T fromMap(Map<String, String> map) throws Exception
{
String key = annotationClass.getSimpleName();
String key = getConfigName();
String value = map.get(key);
if (value == null) {
return defaultValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!set plannerStrategy DECOUPLED
!use druidtest://?NumMergeBuffers=3
!use druidtest://?numMergeBuffers=3
!set outputformat mysql

select cityName, count(case when delta > 0 then channel end) as cnt, count(1) as aall
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!use druidtest://?NumMergeBuffers=3
!use druidtest://?numMergeBuffers=3
!set outputformat mysql

with v as (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!use druidtest://?NumMergeBuffers=3
!use druidtest://?numMergeBuffers=3
!set outputformat mysql

SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!use druidtest://?ComponentSupplier=NestedComponentSupplier
!use druidtest://?componentSupplier=NestedComponentSupplier
!set outputformat mysql

select count(1) from nested;
Expand Down

0 comments on commit 652cc20

Please sign in to comment.