Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ protected Connection createNewConnection(long queryTimestamp) throws SQLExceptio
properties.setProperty("user", trinoUser);
if (config.isSinkMonitorFreshnessEmbedSnapshot())
{
String catalogName = "pixels";
String sessionPropValue = String.format("%s.query_snapshot_timestamp:%d", catalogName, queryTimestamp);
properties.setProperty("sessionProperties", sessionPropValue);
String catalog = parseCatalogFromUrl(trinoJdbcUrl);
if (catalog != null && catalog.equalsIgnoreCase("pixels"))
{
String sessionPropValue = String.format("%s.query_snapshot_timestamp:%d", catalog, queryTimestamp);
properties.setProperty("sessionProperties", sessionPropValue);
}
}
return DriverManager.getConnection(trinoJdbcUrl, properties);
}
Expand Down Expand Up @@ -410,4 +413,34 @@ private List<String> getStaticList()
{
return config.getSinkMonitorFreshnessEmbedTableList();
}

private String parseCatalogFromUrl(String url)
{
if (url == null || !url.startsWith("jdbc:trino://"))
{
return null;
}
String withoutProtocol = url.substring("jdbc:trino://".length());
int slashIndex = withoutProtocol.indexOf('/');
if (slashIndex == -1)
{
return null;
}
String remaining = withoutProtocol.substring(slashIndex + 1);

int nextSlash = remaining.indexOf('/');
int questionMark = remaining.indexOf('?');

int endIndex = remaining.length();
if (nextSlash != -1)
{
endIndex = nextSlash;
}
if (questionMark != -1 && questionMark < endIndex)
{
endIndex = questionMark;
}

return remaining.substring(0, endIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public void pollEvents(SinkProto.PollRequest request, StreamObserver<SinkProto.P
{
SchemaTableName schemaTableName = new SchemaTableName(request.getSchemaName(), request.getTableName());
LOGGER.debug("Received poll request for table '{}'", schemaTableName);
if (freshnessLevel.equals("embed"))
{
FreshnessClient.getInstance().addMonitoredTable(request.getTableName());
}
List<SinkProto.RowRecord> records = new ArrayList<>(pollBatchSize);

try
Expand Down Expand Up @@ -102,11 +106,6 @@ public void pollEvents(SinkProto.PollRequest request, StreamObserver<SinkProto.P
metricsFacade.recordRowEvent(records.size());
metricsFacade.recordTransaction();
this.flushRateLimiter.acquire(records.size());

if (freshnessLevel.equals("embed"))
{
FreshnessClient.getInstance().addMonitoredTable(request.getTableName());
}
}

responseObserver.onNext(responseBuilder.build());
Expand Down