<h3 dir="auto">Description</h3>
<p dir="auto">Currently composing emitter doesn't support having low-level emitter of the same type inside because it instantiates emitters by name</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="return injector.getInstance(Key.get(Emitter.class, Names.named(s)));"><pre class="notranslate"><code class="notranslate">return injector.getInstance(Key.get(Emitter.class, Names.named(s)));
</code></pre></div>
<p dir="auto">Hence composing emitter may contain only one http emitter, one logging emitter, etc.</p>
<h3 dir="auto">Motivation</h3>
<p dir="auto">The goal is to add support of instantiating multiple low-level emitters of the same type using a composing emitter. For example: instantiate multiple http emitters to duplicate metrics event to another endpoint.</p>
<h3 dir="auto">Affected Version</h3>
<p dir="auto">v0.17.0<br>
This is a serious regression bug for us. Queries like the following used to work in Druid 0.16.0 and are broken in 0.17.0<br>
We used Druid 0.17.0 with SQL compatible null handling DISABLED.</p>
<h3 dir="auto">Description</h3>
<p dir="auto">The following query produces a rule error in the SQL engine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="SELECT 
	CASE cityName WHEN NULL THEN FALSE ELSE TRUE END AS col_a,
	CASE countryName WHEN NULL THEN FALSE ELSE TRUE END AS col_b
FROM wikipedia
GROUP BY 1, 2"><pre class="notranslate"><code class="notranslate">SELECT 
	CASE cityName WHEN NULL THEN FALSE ELSE TRUE END AS col_a,
	CASE countryName WHEN NULL THEN FALSE ELSE TRUE END AS col_b
FROM wikipedia
GROUP BY 1, 2
</code></pre></div>
<p dir="auto">the error is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Unknown exception / Error while applying rule DruidQueryRule(AGGREGATE), args [rel#592:LogicalAggregate.NONE.[](input=RelSubset#591,group={0, 1}), rel#599:DruidQueryRel.NONE.[](query={&quot;queryType&quot;:&quot;scan&quot;,&quot;dataSource&quot;:{&quot;type&quot;:&quot;table&quot;,&quot;name&quot;:&quot;wikipedia&quot;},&quot;intervals&quot;:{&quot;type&quot;:&quot;intervals&quot;,&quot;intervals&quot;:[&quot;-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z&quot;]},&quot;virtualColumns&quot;:[{&quot;type&quot;:&quot;expression&quot;,&quot;name&quot;:&quot;v0&quot;,&quot;expression&quot;:&quot;1&quot;,&quot;outputType&quot;:&quot;LONG&quot;}],&quot;resultFormat&quot;:&quot;compactedList&quot;,&quot;batchSize&quot;:20480,&quot;limit&quot;:9223372036854775807,&quot;order&quot;:&quot;none&quot;,&quot;filter&quot;:null,&quot;columns&quot;:[&quot;v0&quot;],&quot;legacy&quot;:false,&quot;context&quot;:{&quot;forceLimitPushDown&quot;:&quot;false&quot;,&quot;sqlOuterLimit&quot;:100,&quot;sqlQueryId&quot;:&quot;f83cf8c0-1856-4dc9-aeb6-fc487b92750f&quot;,&quot;useApproximateTopN&quot;:&quot;false&quot;,&quot;vectorize&quot;:&quot;false&quot;},&quot;descending&quot;:false,&quot;granularity&quot;:{&quot;type&quot;:&quot;all&quot;}},signature={v0:LONG, v0:LONG})] / java.lang.RuntimeException"><pre class="notranslate"><code class="notranslate">Unknown exception / Error while applying rule DruidQueryRule(AGGREGATE), args [rel#592:LogicalAggregate.NONE.[](input=RelSubset#591,group={0, 1}), rel#599:DruidQueryRel.NONE.[](query={"queryType":"scan","dataSource":{"type":"table","name":"wikipedia"},"intervals":{"type":"intervals","intervals":["-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"]},"virtualColumns":[{"type":"expression","name":"v0","expression":"1","outputType":"LONG"}],"resultFormat":"compactedList","batchSize":20480,"limit":9223372036854775807,"order":"none","filter":null,"columns":["v0"],"legacy":false,"context":{"forceLimitPushDown":"false","sqlOuterLimit":100,"sqlQueryId":"f83cf8c0-1856-4dc9-aeb6-fc487b92750f","useApproximateTopN":"false","vectorize":"false"},"descending":false,"granularity":{"type":"all"}},signature={v0:LONG, v0:LONG})] / java.lang.RuntimeException
</code></pre></div>
<p dir="auto">Following is a comparison between what a similar query got translated to in Druid 0.16.0 vs now</p>
<p dir="auto">in 0.16.0:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;queryType&quot;: &quot;groupBy&quot;,
...
  &quot;virtualColumns&quot;: [
    {
      &quot;type&quot;: &quot;expression&quot;,
      &quot;name&quot;: &quot;v0&quot;,
      &quot;expression&quot;: &quot;case_searched((\&quot;integrationType\&quot; == null),0,1)&quot;,
      &quot;outputType&quot;: &quot;LONG&quot;
    },
    {
      &quot;type&quot;: &quot;expression&quot;,
      &quot;name&quot;: &quot;v1&quot;,
      &quot;expression&quot;: &quot;case_searched((\&quot;integrationVersion\&quot; == null),0,1)&quot;,
      &quot;outputType&quot;: &quot;LONG&quot;
    }
  ],
  &quot;dimensions&quot;: [
    {
      &quot;type&quot;: &quot;default&quot;,
      &quot;dimension&quot;: &quot;v0&quot;,
      &quot;outputName&quot;: &quot;v0&quot;,
      &quot;outputType&quot;: &quot;LONG&quot;
    },
    {
      &quot;type&quot;: &quot;default&quot;,
      &quot;dimension&quot;: &quot;v1&quot;,
      &quot;outputName&quot;: &quot;v1&quot;,
      &quot;outputType&quot;: &quot;LONG&quot;
    }
  ],
...
}"><pre class="notranslate"><code class="notranslate">{
  "queryType": "groupBy",
...
  "virtualColumns": [
    {
      "type": "expression",
      "name": "v0",
      "expression": "case_searched((\"integrationType\" == null),0,1)",
      "outputType": "LONG"
    },
    {
      "type": "expression",
      "name": "v1",
      "expression": "case_searched((\"integrationVersion\" == null),0,1)",
      "outputType": "LONG"
    }
  ],
  "dimensions": [
    {
      "type": "default",
      "dimension": "v0",
      "outputName": "v0",
      "outputType": "LONG"
    },
    {
      "type": "default",
      "dimension": "v1",
      "outputName": "v1",
      "outputType": "LONG"
    }
  ],
...
}
</code></pre></div>
<p dir="auto">In v 0.17.0, there seem to be several things that compound:<br>
a) the query is rewritten into a scan query although it augh to be a groupby query<br>
b) the main issue seems to be that instead of recognizing the two CASE statements as being different and generating different logical names "v0" and "v1" for them, the two statements are being given the same name "v0" which is then consecutively leading to an illegal query syntax.<br>
c) instead of faithful CASE expressions, a virtual column expression gets generated that is just a constant number "1"</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
   &quot;queryType&quot;:&quot;scan&quot;,
...
   &quot;virtualColumns&quot;:[
      {
         &quot;type&quot;:&quot;expression&quot;,
         &quot;name&quot;:&quot;v0&quot;,
         &quot;expression&quot;:&quot;1&quot;,
         &quot;outputType&quot;:&quot;LONG&quot;
      }
   ],
   &quot;columns&quot;:[
      &quot;v0&quot;
   ],
...
}"><pre class="notranslate"><code class="notranslate">{
   "queryType":"scan",
...
   "virtualColumns":[
      {
         "type":"expression",
         "name":"v0",
         "expression":"1",
         "outputType":"LONG"
      }
   ],
   "columns":[
      "v0"
   ],
...
}
</code></pre></div>