Skip to content

Commit

Permalink
throw exception if teragrep datasource is queried when its disabled i…
Browse files Browse the repository at this point in the history
…n config (#475)

* throw an exception if archive dataset is constructed when teragrep datasource is disabled in config

* fix an inverse exception message
  • Loading branch information
elliVM authored Jan 23, 2025
1 parent 92d520d commit ea8c843
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/main/java/com/teragrep/pth10/datasources/DPLDatasource.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,11 @@ public DPLDatasource(DPLParserCatalystContext catCtx) {
public Dataset<Row> constructStreams(ArchiveQuery archiveQuery, boolean isMetadataQuery) {
// resolve archive Query which is then used with archiveDatasource
LOGGER.info("DPL Interpreter ArchiveQuery=<[{}]>", archiveQuery);

Dataset<Row> archiveDS = null;
LOGGER.info("DPL Interpreter constructStream config=<[{}]>", config);
// table name per paragraph
if (config.getBoolean("dpl.pth_06.enabled")) {
// Execute search against ArchiveDataSource
archiveDS = archiveStreamConsumerDataset(archiveQuery, isMetadataQuery);
if (!config.getBoolean("dpl.pth_06.enabled")) {
throw new RuntimeException("Teragrep datasource was disabled: <dpl.pth_06.enabled=false>");
}

return archiveDS;
return archiveStreamConsumerDataset(archiveQuery, isMetadataQuery);
}

/**
Expand All @@ -104,7 +99,6 @@ public Dataset<Row> constructStreams(ArchiveQuery archiveQuery, boolean isMetada
*/
private Dataset<Row> archiveStreamConsumerDataset(ArchiveQuery query, boolean isMetadataQuery) {
DataStreamReader reader;

LOGGER.info("ArchiveStreamConsumerDatasource initialized with query: <[{}]>", query);

// setup s3 credentials
Expand Down

0 comments on commit ea8c843

Please sign in to comment.