Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions plugin/trino-pinot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<description>Trino - Pinot connector</description>

<properties>
<dep.pinot.version>1.1.0</dep.pinot.version>
<dep.pinot.version>1.2.0</dep.pinot.version>
<air.compiler.fail-warnings>true</air.compiler.fail-warnings>
<!-- additional JVM flags required by chronicle-hft which is used by pinot-segment spi -->
<air.test.jvm.additional-arguments>${air.test.jvm.additional-arguments.default}
Expand All @@ -25,7 +25,13 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>posix</artifactId>
<version>2.26ea0</version>
<version>2.26ea1</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down Expand Up @@ -152,8 +158,12 @@
<version>${dep.pinot.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
Expand All @@ -171,9 +181,37 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>aopalliance-repackaged</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-entity-filtering</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -215,6 +253,10 @@
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>aopalliance-repackaged</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>aopalliance-repackaged</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>jakarta.inject</artifactId>
Expand Down Expand Up @@ -328,7 +370,7 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>chronicle-core</artifactId>
<version>2.25ea15</version>
<version>2.26ea1</version>
<scope>runtime</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.trino.plugin.pinot.client.PinotHostMapper;
import io.trino.spi.NodeManager;
import io.trino.spi.connector.ConnectorNodePartitioningProvider;
import org.apache.pinot.common.response.broker.BrokerResponseNative;
import org.apache.pinot.common.utils.DataSchema;

import java.io.IOException;
Expand Down Expand Up @@ -90,6 +91,8 @@ public void setup(Binder binder)
});

jsonBinder(binder).addDeserializerBinding(DataSchema.class).to(DataSchemaDeserializer.class);
jsonBinder(binder).addDeserializerBinding(BrokerResponseNative.class).to(BrokerResponseNativeDeserializer.class);

PinotClient.addJsonBinders(jsonCodecBinder(binder));
binder.bind(NodeManager.class).toInstance(nodeManager);
binder.bind(ConnectorNodePartitioningProvider.class).to(PinotNodePartitioningProvider.class).in(Scopes.SINGLETON);
Expand Down Expand Up @@ -120,6 +123,19 @@ public DataSchema deserialize(JsonParser p, DeserializationContext ctxt)
}
}

public static class BrokerResponseNativeDeserializer
Comment thread
wendigo marked this conversation as resolved.
Outdated
extends JsonDeserializer<BrokerResponseNative>
{
@Override
public BrokerResponseNative deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException
{
JsonNode jsonNode = ctxt.readTree(p);
String value = jsonNode.toString();
return BrokerResponseNative.fromJsonString(value);
}
}

public static class PinotGrpcModule
extends AbstractConfigurationAwareModule
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ public TimeBoundary(
{
if (timeColumn != null && timeValue != null) {
// See org.apache.pinot.broker.requesthandler.BaseBrokerRequestHandler::attachTimeBoundary
offlineTimePredicate = Optional.of(format("%s <= %s", timeColumn, timeValue));
onlineTimePredicate = Optional.of(format("%s > %s", timeColumn, timeValue));
offlineTimePredicate = Optional.of(format("%s <= '%s'", timeColumn, timeValue));
Comment thread
wendigo marked this conversation as resolved.
Outdated
onlineTimePredicate = Optional.of(format("%s > '%s'", timeColumn, timeValue));
}
else {
onlineTimePredicate = Optional.empty();
Expand Down Expand Up @@ -557,10 +557,10 @@ private BrokerResponseNative submitBrokerQueryJson(ConnectorSession session, Pin
BrokerResponseNative response = doHttpActionWithHeadersJson(builder, Optional.of(queryRequest), brokerResponseCodec,
additionalHeadersBuilder.build());

if (response.getExceptionsSize() > 0 && response.getProcessingExceptions() != null && !response.getProcessingExceptions().isEmpty()) {
if (response.getExceptionsSize() > 0 && response.getExceptions() != null && !response.getExceptions().isEmpty()) {
// Pinot is known to return exceptions with benign errorcodes like 200
// so we treat any exception as an error
String processingExceptionMessage = response.getProcessingExceptions().stream()
String processingExceptionMessage = response.getExceptions().stream()
.map(e -> "code: '%s' message: '%s'".formatted(e.getErrorCode(), e.getMessage()))
.collect(joining(","));
throw new PinotException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public Iterator<PinotDataTableWithSize> queryPinot(String query, String serverHo
// GrpcQueryClient does not implement Closeable. The idle timeout is 30 minutes (grpc default).
GrpcQueryClient client = clientCache.computeIfAbsent(mappedHostAndPort, hostAndPort -> {
GrpcQueryClient queryClient = proxyUri.isPresent() ? grpcQueryClientFactory.create(HostAndPort.fromString(proxyUri.get())) : grpcQueryClientFactory.create(hostAndPort);
closer.register(queryClient::close);
closer.register(queryClient);
return queryClient;
});
PinotProxyGrpcRequestBuilder grpcRequestBuilder = new PinotProxyGrpcRequestBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
import static org.apache.pinot.common.request.context.ExpressionContext.Type.LITERAL;
import static org.apache.pinot.common.request.context.ExpressionContext.forFunction;
import static org.apache.pinot.common.request.context.ExpressionContext.forIdentifier;
import static org.apache.pinot.common.request.context.ExpressionContext.forLiteralContext;
import static org.apache.pinot.common.request.context.ExpressionContext.forLiteral;
import static org.apache.pinot.core.operator.transform.function.DateTruncTransformFunction.EXAMPLE_INVOCATION;
import static org.apache.pinot.core.operator.transform.transformer.timeunit.TimeUnitTransformerFactory.getTimeUnitTransformer;
import static org.apache.pinot.segment.spi.AggregationFunctionType.COUNT;
Expand Down Expand Up @@ -175,14 +175,14 @@ public FunctionContext rewrite(FunctionContext object, Captures captures, Contex
ImmutableList.Builder<ExpressionContext> argumentsBuilder = ImmutableList.builder();
argumentsBuilder.add(rewriteExpression(object.getArguments().get(0), context));
String inputFormat = object.getArguments().get(1).getLiteral().getValue().toString().toUpperCase(ENGLISH);
argumentsBuilder.add(forLiteralContext(stringValue(inputFormat)));
argumentsBuilder.add(forLiteral(stringValue(inputFormat)));
String outputFormat = object.getArguments().get(2).getLiteral().getValue().toString().toUpperCase(ENGLISH);
argumentsBuilder.add(forLiteralContext(stringValue(outputFormat)));
argumentsBuilder.add(forLiteral(stringValue(outputFormat)));
String granularity = object.getArguments().get(3).getLiteral().getValue().toString().toUpperCase(ENGLISH);
BaseDateTimeTransformer<?, ?> dateTimeTransformer = DateTimeTransformerFactory.getDateTimeTransformer(inputFormat, outputFormat, granularity);
// Even if the format is valid, make sure it is not a simple date format: format characters can be ambiguous due to lower casing
checkState(dateTimeTransformer instanceof EpochToEpochTransformer, "Unsupported date format: simple date format not supported");
argumentsBuilder.add(forLiteralContext(stringValue(granularity)));
argumentsBuilder.add(forLiteral(stringValue(granularity)));
return new FunctionContext(object.getType(), object.getFunctionName(), argumentsBuilder.build());
}
}
Expand Down Expand Up @@ -212,8 +212,8 @@ public FunctionContext rewrite(FunctionContext object, Captures captures, Contex
String outputTimeUnitArgument = object.getArguments().get(2).getLiteral().getValue().toString().toUpperCase(ENGLISH);
// Check that this is a valid time unit transform
getTimeUnitTransformer(inputTimeUnit, outputTimeUnitArgument);
argumentsBuilder.add(forLiteralContext(stringValue(inputTimeUnitArgument)));
argumentsBuilder.add(forLiteralContext(stringValue(outputTimeUnitArgument)));
argumentsBuilder.add(forLiteral(stringValue(inputTimeUnitArgument)));
argumentsBuilder.add(forLiteral(stringValue(outputTimeUnitArgument)));
return new FunctionContext(object.getType(), object.getFunctionName(), argumentsBuilder.build());
}
}
Expand All @@ -239,7 +239,7 @@ public FunctionContext rewrite(FunctionContext object, Captures captures, Contex

checkState(arguments.get(0).getType() == LITERAL, "First argument must be a literal");
String unit = arguments.get(0).getLiteral().getValue().toString().toLowerCase(ENGLISH);
argumentsBuilder.add(forLiteralContext(stringValue(unit)));
argumentsBuilder.add(forLiteral(stringValue(unit)));
verifyIsIdentifierOrFunction(object.getArguments().get(1));
ExpressionContext valueArgument = rewriteExpression(arguments.get(1), context);
argumentsBuilder.add(valueArgument);
Expand All @@ -248,7 +248,7 @@ public FunctionContext rewrite(FunctionContext object, Captures captures, Contex
String inputTimeUnitArgument = arguments.get(2).getLiteral().getValue().toString().toUpperCase(ENGLISH);
// Ensure this is a valid TimeUnit
TimeUnit inputTimeUnit = TimeUnit.valueOf(inputTimeUnitArgument);
argumentsBuilder.add(forLiteralContext(stringValue(inputTimeUnit.name())));
argumentsBuilder.add(forLiteral(stringValue(inputTimeUnit.name())));
if (arguments.size() >= 4) {
checkState(arguments.get(3).getType() == LITERAL, "Unexpected 4th argument '%s'", arguments.get(3));
// Time zone is lower cased inside Pinot
Expand All @@ -258,7 +258,7 @@ public FunctionContext rewrite(FunctionContext object, Captures captures, Contex
String outputTimeUnitArgument = arguments.get(4).getLiteral().getValue().toString().toUpperCase(ENGLISH);
// Ensure this is a valid TimeUnit
TimeUnit outputTimeUnit = TimeUnit.valueOf(outputTimeUnitArgument);
argumentsBuilder.add(forLiteralContext(stringValue(outputTimeUnit.name())));
argumentsBuilder.add(forLiteral(stringValue(outputTimeUnit.name())));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected Type _deserialize(String value, DeserializationContext context)
objectMapperProvider.setJsonDeserializers(ImmutableMap.<Class<?>, JsonDeserializer<?>>builder()
.put(Type.class, new TestingTypeDeserializer())
.put(DataSchema.class, new PinotModule.DataSchemaDeserializer())
.put(BrokerResponseNative.class, new PinotModule.BrokerResponseNativeDeserializer())
.buildOrThrow());
JsonCodecFactory codecFactory = new JsonCodecFactory(objectMapperProvider);
COLUMN_CODEC = codecFactory.jsonCodec(PinotColumnHandle.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.pinot.spi.data.DateTimeFormatSpec;
import org.apache.pinot.spi.data.readers.GenericRow;
import org.apache.pinot.spi.data.readers.RecordReader;
import org.apache.pinot.spi.recordenricher.RecordEnricherPipeline;
import org.apache.pinot.spi.utils.builder.TableNameBuilder;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -646,7 +647,7 @@ record = null;
return record;
};
SegmentIndexCreationDriverImpl driver = new SegmentIndexCreationDriverImpl();
driver.init(segmentGeneratorConfig, dataSource, new TransformPipeline(recordTransformer, null));
driver.init(segmentGeneratorConfig, dataSource, new RecordEnricherPipeline(), new TransformPipeline(recordTransformer, null));
driver.build();
File segmentOutputDirectory = driver.getOutputDirectory();
File tgzPath = new File(String.join(File.separator, outputDirectory, segmentOutputDirectory.getName() + ".tar.gz"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
public class TestingPinotCluster
implements Closeable
{
public static final String PINOT_LATEST_IMAGE_NAME = "apachepinot/pinot:1.1.0";
public static final String PINOT_LATEST_IMAGE_NAME = "apachepinot/pinot:1.2.0";
private static final String ZOOKEEPER_INTERNAL_HOST = "zookeeper";
private static final JsonCodec<List<String>> LIST_JSON_CODEC = listJsonCodec(String.class);
private static final JsonCodec<PinotSuccessResponse> PINOT_SUCCESS_RESPONSE_JSON_CODEC = jsonCodec(PinotSuccessResponse.class);
Expand Down