Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
kgyrtkirk committed Jul 19, 2024
1 parent 361149b commit 31e9732
Show file tree
Hide file tree
Showing 6 changed files with 425 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ protected ExecuteResult doFetch(AbstractDruidJdbcStatement druidStatement, int m
String str = objectMapper
.writerWithDefaultPrettyPrinter()
.writeValueAsString(payload.getStages());
str=str.replaceAll(taskId, "<taskId>");
DruidHook.dispatch(DruidHook.MSQ_PLAN, str);
}
catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ order by 1;
[ {
"stageNumber" : 0,
"definition" : {
"id" : "query-9d38a860-0463-4c5d-b7ed-b2d4e4a0ac6c_0",
"id" : "<taskId>_0",
"input" : [ {
"type" : "table",
"dataSource" : "wikipedia",
Expand Down Expand Up @@ -94,7 +94,7 @@ order by 1;
"finalize" : true,
"maxParseExceptions" : 0,
"plannerStrategy" : "DECOUPLED",
"sqlQueryId" : "9d38a860-0463-4c5d-b7ed-b2d4e4a0ac6c",
"sqlQueryId" : "dd89814f-71a0-4968-ae18-7fb16b354a42",
"sqlStringifyArrays" : false
}
}
Expand Down Expand Up @@ -127,13 +127,13 @@ order by 1;
"partitionCount" : 1,
"shuffle" : "globalSort",
"output" : "localStorage",
"startTime" : "2024-07-19T04:30:50.581Z",
"duration" : 742,
"startTime" : "2024-07-19T11:35:14.021Z",
"duration" : 727,
"sort" : true
}, {
"stageNumber" : 1,
"definition" : {
"id" : "query-9d38a860-0463-4c5d-b7ed-b2d4e4a0ac6c_1",
"id" : "<taskId>_1",
"input" : [ {
"type" : "stage",
"stage" : 0
Expand Down Expand Up @@ -200,7 +200,7 @@ order by 1;
"finalize" : true,
"maxParseExceptions" : 0,
"plannerStrategy" : "DECOUPLED",
"sqlQueryId" : "9d38a860-0463-4c5d-b7ed-b2d4e4a0ac6c",
"sqlQueryId" : "dd89814f-71a0-4968-ae18-7fb16b354a42",
"sqlStringifyArrays" : false
}
}
Expand All @@ -221,9 +221,9 @@ order by 1;
"workerCount" : 1,
"partitionCount" : 1,
"output" : "localStorage",
"startTime" : "2024-07-19T04:30:51.323Z",
"startTime" : "2024-07-19T11:35:14.748Z",
"duration" : 2
} ]
} ]tid:query-dd89814f-71a0-4968-ae18-7fb16b354a42
!msqPlan
LogicalSort(sort0=[$0], dir0=[ASC])
LogicalAggregate(group=[{0}], cnt=[COUNT($1)], aall=[COUNT()])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Package-private since it is not intended to be used outside that narrow use case. In other cases where passing
* around information about column types is important, use {@link ColumnType} instead.
*/
class ColumnSignature
public /*FIXME*/ class ColumnSignature
{
private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public int indexOf(final String columnName)
}

@JsonValue
private List<ColumnSignature> asColumnSignatures()
public List<ColumnSignature> asColumnSignatures()
{
final List<ColumnSignature> retVal = new ArrayList<>();

Expand Down
212 changes: 212 additions & 0 deletions quidem-it/src/main/java/org/apache/druid/quidem/A11.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
/*
* 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.quidem;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultIndenter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import org.apache.druid.msq.indexing.report.MSQResultsReport.ColumnAndType;
import org.apache.druid.segment.column.ColumnSignature;
import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.segment.column.RowSignature;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class A11
{
static class CustomCollapedIntender implements DefaultPrettyPrinter.Indenter
{
boolean isInside = false;

@Override
public boolean isInline()
{
return false;// getDelegate().isInline();
}

private DefaultPrettyPrinter.Indenter getDelegate()
{
if (isInside) {
return new DefaultPrettyPrinter.NopIndenter();
} else {
return DefaultIndenter.SYSTEM_LINEFEED_INSTANCE;

}
}

@Override
public void writeIndentation(JsonGenerator g, int level) throws IOException
{
if (isX(g)) {
}
isInside = isX(g);
if (isInside) {
int asd = 1;
}
getDelegate().writeIndentation(g, level);
}

private boolean isX(JsonGenerator g)
{
Object v = g.getCurrentValue();

return v instanceof ColumnSignature;
// return false;
// return v instanceof RowSignature;
// return g.getCurrentValue() instanceof List;

}

}

static class aa extends DefaultPrettyPrinter
{

public aa()
{
super();
_objectIndenter = new CustomCollapedIntender();
}

@Override
public DefaultPrettyPrinter createInstance()
{
return new aa();
}

// @Override
// public void writeObjectEntrySeparator(JsonGenerator g) throws IOException
// {
// g.writeRaw(_separators.getObjectEntrySeparator());
// _objectIndenter.writeIndentation(g, _nesting);
// }

@Override
public void writeStartArray(JsonGenerator g) throws IOException
{
Object cv = g.getCurrentValue();
if (isX(g)) {
g.setPrettyPrinter(new MinimalPrettyPrinter());
}
super.writeStartArray(g);

}

@Override
public void writeObjectEntrySeparator(JsonGenerator g) throws IOException
{

super.writeObjectEntrySeparator(g);
}

@Override
public void writeStartObject(JsonGenerator g) throws IOException
{
super.writeStartObject(g);
}

public void writeEndObject1(JsonGenerator g, int nrOfEntries) throws IOException
{
Indenter old = _objectIndenter;
if (isX(g)) {
_objectIndenter = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE;
}
super.writeEndObject(g, nrOfEntries);
if (isX(g)) {
_objectIndenter = old;
}
}

private boolean isX(JsonGenerator g)
{
Object v = g.getCurrentValue();
return v instanceof ColumnSignature;
// return g.getCurrentValue() instanceof List;

}

@Override
public void writeEndArray(JsonGenerator g, int nrOfValues) throws IOException
{
Object cv = g.getCurrentValue();
super.writeEndArray(g, nrOfValues);

}
}

static class Asd
{
@JsonProperty
int asd = 11;
@JsonProperty
RowSignature rs;
@JsonProperty
ColumnAndType or = new ColumnAndType("Asd", ColumnType.DOUBLE);

Asd()
{
rs = RowSignature.builder()
.add("s", ColumnType.STRING)
.add("d", ColumnType.DOUBLE)
.add("d1", ColumnType.LONG)
.build();
asd = 1111;
}
}

@Test
public void sdf() throws JsonProcessingException
{
ObjectMapper om = new ObjectMapper();
om.setAnnotationIntrospector(new JacksonAnnotationIntrospector()
{
@Override
public boolean hasIgnoreMarker(final AnnotatedMember m)
{
List<String> exclusions = Arrays.asList("asd");
return exclusions.contains(m.getName()) || super.hasIgnoreMarker(m);
}
});
ObjectWriter w = om.writer(new DefaultPrettyPrinter().withObjectIndenter(new CustomCollapedIntender()));

final RowSignature.Builder builder = RowSignature.builder()
.add("s", ColumnType.STRING)
.add("d", ColumnType.DOUBLE)
.add("d1", ColumnType.LONG);

List<org.apache.druid.segment.column.ColumnSignature> cs = builder.build().asColumnSignatures();

// String s = w.writeValueAsString(builder.build());
String s = w.writeValueAsString(new Asd());
System.out.println(s);

}

}
Loading

0 comments on commit 31e9732

Please sign in to comment.