mirror of https://github.com/apache/druid.git
Allow using jsonpath predicates with AvroFlattener (#10330)
This commit is contained in:
parent
ede25f1b45
commit
20ca9aaaf7
|
@ -193,6 +193,6 @@ public class GenericAvroJsonProvider implements JsonProvider
|
||||||
@Override
|
@Override
|
||||||
public Object unwrap(final Object o)
|
public Object unwrap(final Object o)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("Unused");
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.druid.data.input.AvroStreamInputRowParserTest;
|
||||||
import org.apache.druid.data.input.SomeAvroDatum;
|
import org.apache.druid.data.input.SomeAvroDatum;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AvroFlattenerMakerTest
|
public class AvroFlattenerMakerTest
|
||||||
{
|
{
|
||||||
|
@ -195,6 +197,22 @@ public class AvroFlattenerMakerTest
|
||||||
record.getSomeRecordArray(),
|
record.getSomeRecordArray(),
|
||||||
flattener.makeJsonPathExtractor("$.someRecordArray").apply(record)
|
flattener.makeJsonPathExtractor("$.someRecordArray").apply(record)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Assert.assertEquals(
|
||||||
|
record.getSomeRecordArray().get(0).getNestedString(),
|
||||||
|
flattener.makeJsonPathExtractor("$.someRecordArray[0].nestedString").apply(record)
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.assertEquals(
|
||||||
|
record.getSomeRecordArray(),
|
||||||
|
flattener.makeJsonPathExtractor("$.someRecordArray[?(@.nestedString)]").apply(record)
|
||||||
|
);
|
||||||
|
|
||||||
|
List<String> nestedStringArray = Collections.singletonList(record.getSomeRecordArray().get(0).getNestedString().toString());
|
||||||
|
Assert.assertEquals(
|
||||||
|
nestedStringArray,
|
||||||
|
flattener.makeJsonPathExtractor("$.someRecordArray[?(@.nestedString=='string in record')].nestedString").apply(record)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
@Test(expected = UnsupportedOperationException.class)
|
||||||
|
|
Loading…
Reference in New Issue